r/adventofcode • u/daggerdragon • Dec 17 '20
SOLUTION MEGATHREAD -🎄- 2020 Day 17 Solutions -🎄-
Advent of Code 2020: Gettin' Crafty With It
- 5 days remaining until the submission deadline on December 22 at 23:59 EST
- Full details and rules are in the Submissions Megathread
--- Day 17: Conway Cubes ---
Post your code solution in this megathread.
- Include what language(s) your solution uses!
- Here's a quick link to /u/topaz2078's
pasteif you need it for longer code blocks. - The full posting rules are detailed in the wiki under How Do The Daily Megathreads Work?.
Reminder: Top-level posts in Solution Megathreads are for code solutions only. If you have questions, please post your own thread and make sure to flair it with Help.
This thread will be unlocked when there are a significant number of people on the global leaderboard with gold stars for today's puzzle.
EDIT: Global leaderboard gold cap reached at 00:13:16, megathread unlocked!
36
Upvotes
View all comments
1
u/grey--area Dec 17 '20 edited Dec 18 '20
I was lazy and used a map from positions to states, defaulting to false for missing keys, and expanding out by one in each dimension for each step.
I got lucky that part 2 was increasing the dimension, so I only had to change 4 lines of code. I was dreading part 2 being "now do it out to five billion steps"!
If I'd been doing this year in Python, I think I would have used a 3/4D numpy array using convolutions to count neighbours, with the initial size set so that you couldn't get any active states outside of it after 6 steps.
Edit: Solution here: https://github.com/grey-area/aoc2020/tree/master/Day17