This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2017-12-22
Channels
- # adventofcode (37)
- # beginners (74)
- # boot (2)
- # boot-dev (31)
- # cider (88)
- # clara (109)
- # cljs-dev (63)
- # clojure (96)
- # clojure-argentina (1)
- # clojure-czech (1)
- # clojure-dusseldorf (2)
- # clojure-france (2)
- # clojure-germany (3)
- # clojure-greece (2)
- # clojure-italy (5)
- # clojure-norway (1)
- # clojure-spain (1)
- # clojure-spec (25)
- # clojure-uk (46)
- # clojurescript (26)
- # cursive (19)
- # data-science (5)
- # docs (2)
- # duct (18)
- # editors (2)
- # emacs (3)
- # figwheel (2)
- # fulcro (29)
- # graphql (3)
- # hoplon (143)
- # juxt (7)
- # klipse (1)
- # leiningen (5)
- # lumo (1)
- # monads (1)
- # off-topic (23)
- # onyx (49)
- # powderkeg (6)
- # re-frame (4)
- # reagent (8)
- # ring (3)
- # shadow-cljs (24)
- # specter (70)
- # sql (1)
- # unrepl (96)
- # yada (3)
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 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.
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.
My code: https://github.com/orestis/adventofcode/blob/master/clojure/aoc/src/aoc/2017_day21.clj
Day 22: https://github.com/mfikes/advent-of-code/blob/master/src/advent_2017/day_22.cljc
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
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
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
’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