popa.bogdanp
2021-12-5 09:33:38

I also went with a sparse map initally, but then converted to a dense fxvector to squeeze out more speed (part 2 went from about 95ms to 10ms).

https://github.com/Bogdanp/aoc2021/blob/master/day05.rkt


massung
2021-12-5 14:59:57

I almost initially went down the intersect road, but then figured the # of lines of real data would be large enough that the exponential nature would be killer w/o something like a quad tree


massung
2021-12-5 15:57:56

Just curious if your timing includes parsing time?


massung
2021-12-5 15:58:54

Mine takes ~70ms, but that includes parsing. And my re package (self-rolled) is definitely not as fast as cl-ppcre


popa.bogdanp
2021-12-5 16:00:31

No, it doesn’t include parsing time, but I just tested it and parsing’s under 1ms.


ben.knoble
2021-12-5 16:15:31

I’m using lists and values—200ms/400ms for part1/part2. (This is after starting with rebellion’s transducers and multisets—turns out they are really slow (6+s). You can see the optimization history in the commits: https://github.com/benknoble/advent2021/commits/main/day5)


popa.bogdanp
2021-12-6 05:36:28

Day 6 spoilers :thread:


popa.bogdanp
2021-12-6 05:36:46

This year really seems to be the year of sparse representations, huh. Or is there a math-y solution here?


popa.bogdanp
2021-12-6 05:37:22

soegaard2
2021-12-6 05:58:28

Nice and clean!


popa.bogdanp
2021-12-6 06:04:42

Thanks!


massung
2021-12-6 07:25:29

Frustrated with todays. I spent quite a while wracking my brain, because I’m fairly confident this is a simple summation equation/population growth.


massung
2021-12-6 07:28:28

I spent time refreshing myself with https://en.wikipedia.org/wiki/Triangular_number, but at 1am, I don’t think I was going to make a breakthrough, and just went for memoization. :wink:


soegaard2
2021-12-6 07:36:44

FWIW the definitions in racket/math are: (: triangle-number : Natural -> Natural) (define (triangle-number n) (quotient (* n (+ n 1)) 2)) (: triangle-number? : Natural -> Boolean) (define (triangle-number? n) (not (null? (quadratic-natural-solutions 1/2 1/2 (- n)))))