Fork me on GitHub
#adventofcode
<
2021-12-20
>
alekszelark04:12:03

🧵Day 20 Solutions Thread: post your solution here

norman07:12:41

https://gitlab.com/maximoburrito/advent2021/-/blob/main/src/day20/main.clj I'd feel bad about the solution here, but after day 19 I'm just happy to be done

alekszelark07:12:12

@U0954HGDQ a hint about infinity is a blinking void

norman07:12:12

Yeah, I had that but I was deferring to part 2 to figure how I needed to worry about it. I hacked around it and then found out part2 just needed a slightly larger constant in the hack... wheeee

alekszelark07:12:21

Yeah, I read your comments in the code 🙂

Antonio Bibiano11:12:56

I was like, now way i need to light up infinitely many pixels..and indeed i needed to 😄

♾️ 2
Callum Oakley11:12:11

nice twist. part 2 is pretty slow but I need a break from optimising after yesterday… 😅 200ms/9s https://github.com/callum-oakley/advent-of-code/blob/main/src/aoc/2021/20.clj

👏 1
Antonio Bibiano12:12:22

mhhh..went with adding a border that changes each iteration pretty slow for the second part, maybe there is something that I'm doing that is obviously slow?

alekszelark12:12:58

@U01HY37QQUA actually you don’t need a border

Antonio Bibiano12:12:30

yeah I could have gone with using a map for my grid, but i didn't want to iterate using indices, but probably that would have turned out better

Callum Oakley12:12:30

I used the set of pixels that are on, or the set of pixels that are off. one of the two is always finite

kevinc16:12:57

https://github.com/kconner/advent-of-code/blob/master/2021/20a.cljhttps://github.com/kconner/advent-of-code/blob/master/2021/20b.clj. 75ms and 10s. Instead of computing a number for each group of 9 pixels in an enhancement pass and using that to look up, which I supposed might be a bottleneck, I built the groups into the lookup table and used it as the lookup object. I don't know if that's actually faster in the end.

tschady17:12:57

same kind of solution as others. 95ms / 5s https://github.com/tschady/advent-of-code/blob/main/doc/2021.adoc#aoc2021d20 Only interesting thing I do is :field (cycle [\0 \1]) and (update :field rest) to oscillate between values at infinity.

karol20:12:48

https://github.com/kfirmanty/advent-of-code-2021/blob/main/src/day20.clj went for a quick and dirty solution for day20. As in my lookup table first pixel was # and last . I just assumed that infinite board periodically flashes so each turn I alternated between either getting # or . when reaching outside of the board

Sam Adams21:12:15

Especially gross code, hacky perimeter-flash logic — hoping to catch up today since I missed the last two days. https://samadams.dev/2021/12/20/advent-of-code-day-20.html

👍 4