Fork me on GitHub
#adventofcode
<
2017-12-25
>
minikomi02:12:22

super far behind because of end of year work 😕

minikomi02:12:46

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

minikomi04:12:19

weird.. got day21/1 but not /2

minikomi05:12:39

any easy overlooked-rule type bugs? keep getting the wrong output for part2 😕

fellshard06:12:47

Heheh, you actually parsed the directions from the file. 😄

fellshard06:12:58

I took the boring way out to start

fellshard06:12:02

Maybe I'll do that later 🙂

mfikes06:12:04

Yeah, I was tempted to just write it in code 🙂

mfikes06:12:18

Especially since the input was so short 🙂

borkdude07:12:35

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

borkdude07:12:10

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

ihabunek10:12:20

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 🙂

ihabunek10:12:50

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

ihabunek10:12:23

ah, iterate

ihabunek10:12:35

i tend start with loop/recur and forget about iterate

ihabunek10:12:44

how fast is yours?

ihabunek10:12:50

mine takes a bit, ~15s

ihabunek10:12:05

ah, i see the comment, 10s

borkdude10:12:05

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

borkdude10:12:55

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

ihabunek10:12:21

yeah, saw that

ihabunek10:12:29

but depends on the language i guess

borkdude10:12:41

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

ihabunek10:12:46

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

ihabunek10:12:53

on my laptop it takes 15ish

borkdude10:12:04

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

borkdude10:12:48

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

ihabunek10:12:39

@borkdude need to examine that 🙂

borkdude11:12:35

@ihabunek

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

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

ihabunek11:12:59

right, seqs have some overhead

ihabunek11:12:09

i learned that on one of the earlier days

borkdude11:12:00

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.

thegeez12:12:12

Mission accomplished! Thanks everybody that was fun

tbaldridge13:12:15

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

borkdude20:12:59

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

mfikes13:12:47

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.

mfikes14:12:07

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

bhauman20:12:27

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

bhauman20:12:48

Merry Holidays!

tbaldridge20:12:20

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