super far behind because of end of year work π
maybe i'll try to squeeze today in then fill in the past days
weird.. got day21/1 but not /2
https://github.com/minikomi/advent-of-code/blob/master/src/advent/2017/day21.clj
any easy overlooked-rule type bugs? keep getting the wrong output for part2 π
Day 25: https://github.com/mfikes/advent-of-code/blob/master/src/advent_2017/day_25.cljc
Heheh, you actually parsed the directions from the file. π
I took the boring way out to start
Maybe I'll do that later π
Yeah, I was tempted to just write it in code π
Especially since the input was so short π
Today was easy. I think the ethical thing of them to do, to have a nice Christmas day with the family π
Thanks all for the fun times in here the last 25 days!
Nice t-shirt: https://teespring.com/advent-of-code-eu#pid=389&cid=100029&sid=front
i skipped parsing of input today, not a part i really enjoy, and very simple to convert to a clojure structure in an editor using multicursors π
i was also slightly afraid that they will come up with something terrible today
my code, nothing very clever: https://github.com/ihabunek/aoc2017/blob/master/src/aoc2017/day25.clj
@ihabunek very similar to mine π https://github.com/borkdude/aoc2017/blob/master/src/day25.clj
ah, iterate
i tend start with loop/recur and forget about iterate
how fast is yours?
mine takes a bit, ~15s
ah, i see the comment, 10s
iterate applies to a lot of solutions. 10s over here on a Macbook Pro 15" 2015
Iβve read somewhere in an article that all puzzles should run below or around 10s on 10year old hardware
yeah, saw that
but depends on the language i guess
Right, I think he means when youβre using a mutable language like Java or C
on my desktop (bash on windows, i5), your solution takes 8s, and mine takes 6s
on my laptop it takes 15ish
And we can get to that speed, @mfikes and I got to world domination on day 5: https://github.com/borkdude/aoc2017/blob/master/src/day05.clj#L115
Yes, loop recur is somewhat faster than iterate I think, because it doesnβt construct a seq
@borkdude need to examine that π
(time
(loop [counter 0]
(if (= counter 100000000)
counter
(recur (inc counter))))) ;; 33ms
(time (nth (iterate inc 0) 100000000)) ;; 2797 ms
right, seqs have some overhead
i learned that on one of the earlier days
Slightly faster:
(time
(transduce
(drop 100000000)
(fn
([] nil)
([acc] acc)
([acc n]
(reduced (or acc n))))
(iterate inc 0))) ;; 1915ms
Not sure if there is anything better with transducers + iterate to make the overhead smaller.Mission accomplished! Thanks everybody that was fun
@borkdude in newer versions of Clojure (1.8+ IIRC) that can be done with (range) instead of (iterate). If the input args are longs there's a fastpath in Clojure that produces a reducible that stores the state as unboxed longs.
On my hardware, the transduce
over iterate
above takes 2071 ms in the clj
REPL. With the update to iterate
in ClojureScript master, in Planck this same form takes 1779 ms.
Interestingly in the node REPL the first execution takes around 750 ms, and subsequent ones drop back down to 1800 ms.
https://github.com/bhauman/advent-of-clojure-2016/blob/master/src/advent_of_clojure_2017/day25.clj
It's been super fun and educational to do this with you all! Thanks for everything!
Merry Holidays!
This is a type of project where Cljs really shines. The JS jits are much better at auto unboxing
The input arg for my typical use arenβt ints, I just need the behavior of iterate to produce successive game states