Hah. I forgot core has even?
—no need to (zero? (mod x 2))
On a more interesting note, I sorted out how to transduce all the way through with no intermediate data structures
https://github.com/mfikes/advent-of-code/commit/c8e5873603d459909f464036e912b3dca0f71562
This results in it processing an arbitrary number of iterations without blowing out memory
The mind bending bit is to replace an (into [] ...)
in the core of the algorithm with an (eduction ..)
which causes all the steps to complete immediately, followed by a long phase of another transduce at the end where it does all the calculations essentially lazily.
The learning: you can iterate
where each step returns an eduction
. Cool!
that's impressive
i need to study your code, it's way above my current understanding of clojure 🙂
Bah. Day 21 is so fiddly.
You can have both rotations and flips?
Arg.
Phew, I had the rotations/flips logic wrong, I got a hint from @borkdude and now my code works for both parts, even though I didn’t take into account any ordering or whatever.
Now to read other code.
My code: https://github.com/orestis/adventofcode/blob/master/clojure/aoc/src/aoc/2017_day21.clj
@bhauman Ahh, fantastic transpose/flip/rotate functions.
Day 22: https://github.com/mfikes/advent-of-code/blob/master/src/advent_2017/day_22.cljc
The motivation is that if you do it this way in ClojureScript, you work around the lack of locals clearing. In other words, in CloureScript you are always holding head.
The patch that helps tremendously in ClojureScript for problems involving reducing over large amounts of iterate
, repeat
and cycle
(which a lot of the AoC problems seem to do) is now in https://dev.clojure.org/jira/browse/CLJS-2445
Day 22: https://github.com/borkdude/aoc2017/blob/master/src/day22.clj
https://github.com/bhauman/advent-of-clojure-2016/blob/master/src/advent_of_clojure_2017/day22.clj
just increase the complexity of the state transitions and it will have to take more time
this seems to be their strategy this year
is that different than last year? I stopped at day 7 or so last year
if I remember correctly they had more stumpers in the last two advents
maybe they’re trying to make it more mainstream now? 😉
if you’re bored with today’s ant, here’s another game: https://github.com/wouter-swierstra/ants/blob/master/ants.pdf
I remember last year to be more about best first searching, this year iterate seems to always suffice
Last year there was A* and other graph search algorithms.
Still being at '15 day 22 you guys won't motivate me to look into '16 and '17 ☺️
’17 feels much easier. Usually the last couple of days are simple, what with people solving the puzzle over the holidays.
My Day 22: https://github.com/orestis/adventofcode/blob/master/clojure/aoc/src/aoc/2017_day22.clj
This year for some reason I really don’t want to refactor any code. I wonder if Clojure is scaring me.
FWIW, I refactor heavily. The first version I write works but is garbage. 🙂
Same for me.
is there an ascicinema like way to record what happens in an emacs buffer?
well i guess I could run in the terminal
which shouldn't be too hard