adventofcode

Happy Advent 2020! Please put answers in the pinned threads or create one if it does not exist yet. | https://github.com/adventofcode-clojurians/adventofcode-clojurians | Join the private leaderboard with code 217019-4a55b8eb
2017-12-25T02:44:22.000027Z

super far behind because of end of year work πŸ˜•

2017-12-25T02:44:46.000068Z

maybe i'll try to squeeze today in then fill in the past days

2017-12-25T04:24:19.000024Z

weird.. got day21/1 but not /2

2017-12-25T05:01:39.000098Z

any easy overlooked-rule type bugs? keep getting the wrong output for part2 πŸ˜•

fellshard 2017-12-25T06:14:47.000036Z

Heheh, you actually parsed the directions from the file. πŸ˜„

fellshard 2017-12-25T06:14:58.000087Z

I took the boring way out to start

fellshard 2017-12-25T06:15:02.000085Z

Maybe I'll do that later πŸ™‚

mfikes 2017-12-25T06:15:04.000082Z

Yeah, I was tempted to just write it in code πŸ™‚

mfikes 2017-12-25T06:15:18.000123Z

Especially since the input was so short πŸ™‚

borkdude 2017-12-25T07:30:35.000015Z

Today was easy. I think the ethical thing of them to do, to have a nice Christmas day with the family πŸ˜‰

borkdude 2017-12-25T07:36:10.000061Z

Thanks all for the fun times in here the last 25 days!

πŸ’― 5
🀘 1
ihabunek 2017-12-25T10:10:20.000115Z

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 πŸ™‚

ihabunek 2017-12-25T10:10:50.000020Z

i was also slightly afraid that they will come up with something terrible today

ihabunek 2017-12-25T10:49:33.000046Z

my code, nothing very clever: https://github.com/ihabunek/aoc2017/blob/master/src/aoc2017/day25.clj

borkdude 2017-12-25T10:51:03.000079Z

@ihabunek very similar to mine πŸ™‚ https://github.com/borkdude/aoc2017/blob/master/src/day25.clj

ihabunek 2017-12-25T10:51:23.000013Z

ah, iterate

ihabunek 2017-12-25T10:51:35.000080Z

i tend start with loop/recur and forget about iterate

ihabunek 2017-12-25T10:51:44.000059Z

how fast is yours?

ihabunek 2017-12-25T10:51:50.000062Z

mine takes a bit, ~15s

ihabunek 2017-12-25T10:52:05.000005Z

ah, i see the comment, 10s

borkdude 2017-12-25T10:52:05.000070Z

iterate applies to a lot of solutions. 10s over here on a Macbook Pro 15" 2015

borkdude 2017-12-25T10:52:55.000038Z

I’ve read somewhere in an article that all puzzles should run below or around 10s on 10year old hardware

ihabunek 2017-12-25T10:53:21.000038Z

yeah, saw that

ihabunek 2017-12-25T10:53:29.000011Z

but depends on the language i guess

borkdude 2017-12-25T10:53:41.000080Z

Right, I think he means when you’re using a mutable language like Java or C

ihabunek 2017-12-25T10:54:46.000066Z

on my desktop (bash on windows, i5), your solution takes 8s, and mine takes 6s

ihabunek 2017-12-25T10:54:53.000048Z

on my laptop it takes 15ish

borkdude 2017-12-25T10:55:04.000008Z

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

borkdude 2017-12-25T10:55:48.000020Z

Yes, loop recur is somewhat faster than iterate I think, because it doesn’t construct a seq

ihabunek 2017-12-25T10:57:39.000008Z

@borkdude need to examine that πŸ™‚

borkdude 2017-12-25T11:00:35.000094Z

@ihabunek

(time
   (loop [counter 0]
     (if (= counter 100000000)
       counter
       (recur (inc counter))))) ;; 33ms

(time (nth (iterate inc 0) 100000000)) ;; 2797 ms

ihabunek 2017-12-25T11:00:59.000117Z

right, seqs have some overhead

ihabunek 2017-12-25T11:01:09.000035Z

i learned that on one of the earlier days

borkdude 2017-12-25T11:08:00.000047Z

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.

2017-12-25T12:58:12.000078Z

Mission accomplished! Thanks everybody that was fun

πŸ‘ 1
2017-12-25T13:41:15.000003Z

@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.

mfikes 2017-12-25T13:57:47.000077Z

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.

mfikes 2017-12-25T14:01:07.000068Z

Interestingly in the node REPL the first execution takes around 750 ms, and subsequent ones drop back down to 1800 ms.

bhauman 2017-12-25T20:11:27.000084Z

It's been super fun and educational to do this with you all! Thanks for everything!

bhauman 2017-12-25T20:11:48.000033Z

Merry Holidays!

2017-12-25T20:37:20.000026Z

This is a type of project where Cljs really shines. The JS jits are much better at auto unboxing

borkdude 2017-12-25T20:59:59.000005Z

The input arg for my typical use aren’t ints, I just need the behavior of iterate to produce successive game states