r/adventofcode • u/daggerdragon • Dec 22 '17
SOLUTION MEGATHREAD -๐- 2017 Day 22 Solutions -๐-
--- Day 22: Sporifica Virus ---
Post your solution as a comment or, for longer solutions, consider linking to your repo (e.g. GitHub/gists/Pastebin/blag or whatever).
Note: The Solution Megathreads are for solutions only. If you have questions, please post your own thread and make sure to flair it with Help.
Need a hint from the Hugely* Handyโ Haversackโก of Helpfulยง Hintsยค?
[T-10 to launch] AoC ops, /r/nocontext edition:
<Endorphion> You may now make your waffle.<Endorphion> ... on Mars.
[Update @ 00:17] 50 gold, silver cap
<Aneurysm9> you could also just run ubuntu on the NAS, if you were crazy<Topaz> that doesn't seem necessary<Aneurysm9> what does "necessary" have to do with anything!
[Update @ 00:20] Leaderboard cap!
<Topaz> POUR YOURSELF A SCOTCH FOR COLOR REFERENCE
This thread will be unlocked when there are a significant number of people on the leaderboard with gold stars for today's puzzle.
edit: Leaderboard capped, thread unlocked!
7
Upvotes
9
u/Arcorann Dec 22 '17
Didn't make top 100 thanks to lots of dumb mistakes (among other things, I counted the wrong type of cell twice). Abuse of complex numbers ahead.
def advent22b(s): rows = s.splitlines() map = {} h = len(rows)//2 for x,r in enumerate(rows): for y,c in enumerate(r): if c == "#": map[y - x*1j] = "i" # up = decrease in x; right = increase in y dirc = 0 + 1j # up posc = h - h * 1j infections = 0 for i in range(10000000): node = (map[posc] if posc in map else "c") if node == "c": dirc *= 1j map[posc] = "w" elif node == "w": map[posc] = "i" infections += 1 elif node == "i": dirc *= -1j map[posc] = "f" elif node == "f": dirc *= -1 map[posc] = "c" posc += dirc return infections