5 ms·
Day 22 (https://adventofcode.com/2021/day/22 https://adventofcode.com/2021/day/22) is the one that nearly killed me in 2021. I did get it using a technique of b
by Volundr 4y ago
Day 22 (https://adventofcode.com/2021/day/22 https://adventofcode.com/2021/day/22) is the one that nearly killed me in 2021. I did get it using a technique of breaking any overlaps into smaller and smaller rectangles, but it took like 30s to run. I looked on the AoC reddit, and honestly I still don't understand what I needed to do to make it better, but visualizing 3d spaces has always been a weakness for me.
- tialaramex 4y agoMy target is usually 1 second each, because that feels about right for my patience, rather than 1 second overall target. My 2021 (Rust) solutions all meet that, but some only do so when optimized, and day 22 was one of those where without the optimizer I'm waiting 2-3 seconds for an answer. IIRC the trick was to compact the indices, so e.g instead of thinking about X values of 120203 494302 and 109383 you call those 1, 2, 0. Do all the working out of which cells within the resulting tiny structure are on or off, and then expand the 1x1 cells you're talking about to their true size based on the real values instead of indices.
- orlp 4y agoMy day 22 solution runs in <10ms: https://github.com/orlp/aoc2021/blob/master/src/bin/day22.rs https://github.com/orlp/aoc2021/blob/master/src/bin/day22.rs The trick I used was to represent signed volumes, compute the intersection and then store the 'negative cube' instead of splitting up cubes.
- sordina 4y agoYeah same! It really was a tricky one for me: https://github.com/sordina/advent2021/blob/solutions/src/Advent22b.hs https://github.com/sordina/advent2021/blob/solutions/src/Adv...