yes, I tried an "optimization" in my 33 minute solution that took it to 45 π
@misha there's aset-int
too; I got no reflection warnings when using that and no type hints a single type hint on the array itself
Yeah, I saw it in your code, TIL :opieop:
https://github.com/euccastro/advent-of-code-2020/blob/master/src/advent/day24.clj
I lucked out on this one, since I'd worked with hex grids a while ago: https://wiki.call-cc.org/eggref/4/hexgrid [P.S.; NB I'm not using that coord system here, but a simpler one with y pointing northwest and x pointing east.]
https://github.com/green-coder/advent-of-code-2020/blob/master/src/aoc/day_24.clj
I was a game programmer, so I know my bestagon :-)
Good morning. Today, a video about the bestagons. https://www.youtube.com/watch?v=thOifuHs6eY
I wasted 20 minutes on >= 2
vs > 2
:picard-facepalm:
@zelark I was thinking about you when I saw that it was once again about neighbors.
I missed this first
initially so my solution2 was running forever and I got really scared that there was some combinatorial madness going on again π
https://github.com/euccastro/advent-of-code-2020/blob/9e9cabf2fcd8ea8383ec193696ec9ebdb81be400/src/advent/day24.clj#L84
a bit confused on the instructions for part 2
are we supposed to use the colors determined from part 1 as the starting point?
@markw Yes
ok good to know π
Thanks to what I learned on day 17 from @zelark's code (and for the fact that I have been taking notes each day), part 2 went faster than part 1. https://github.com/rjray/advent-2020-clojure/blob/master/src/advent_of_code/day24.clj
And here is mine π https://github.com/zelark/AoC-2020/blob/master/src/zelark/aoc_2020/day_24.clj
As expected, frequencies
was frequently used.
just leave it here ^_^
(defn stepper [neighbours birth? survive?]
(fn [cells]
(set (for [[loc n] (frequencies (mapcat neighbours cells))
:when (if (cells loc) (survive? n) (birth? n))]
loc))))
(stepper neighbours #{2} #{1 2})
description of the coordinate system @vincent.cantin and me used: https://www.redblobgames.com/grids/hexagons/#coordinates-axial
only our y points northwest
@vincent.cantin @zelark nice touch on using re-seq
to parse the line. I'll borrow that to remove my silly str/replace
s π
I guess I wasn't sure enough that re-seq
would do the right (greedy) thing..
> βThere is a REPL for thatβ
true true...
somehow that makes my code a bit slower... but I'll keep it anyway since it reads much better
after revisiting the redblobgames article and choosing right coordinate system it was easy https://github.com/nbardiuk/adventofcode/blob/master/2020/src/day24.clj
https://www.reddit.com/r/adventofcode/comments/kjev7f/2020_day_24_part_2_i_let_it_run_for_10m/
Anyone wants to check it? :)))
Above 1 million iterations, it's called Crab-coin.
Bestagons found...
I'm just crossing my fingers that we don't get another Zork like last year's day 25...
I was too lazy and relaxed to write an algorithm for that, so just I played in it as it was a game, and got my 2 stars in the end.
For tomorrowβs puzzle, I randomly predict a path finding problem.
Same. I used math.combinatorics
to generate the sets of items to hold at once. According to last yearβs notes, this got me a ranking of 635 on part 1.
I would welcome that. I have plenty of prior art that I can (try to) adapt for that.