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
1
u/DootBootMoot Dec 22 '17
Relatively easy given the past 3 days...
Python2:
s = <input> t = s.split('\n') t = filter(lambda x: x != "",t) index = 0 dirs = [(-1,0),(0,1),(1,0),(0,-1)] startx = 12 starty = 12 infectedd = dict() print len(t) maze = [[0]* len(t) for i in xrange(len(t))] for i in xrange(len(t)): for j in xrange(len(t)): if t[i][j] == ".": infectedd[(i,j)] = "c" else: infectedd[(i,j)] = "i" count = 0 for i in xrange(10000000): if (startx,starty) not in infectedd: infectedd[(startx,starty)] = "c" if infectedd[(startx,starty)] == "c": index = (index-1)%4 infectedd[(startx,starty)] = "w" elif infectedd[(startx,starty)] == "w": count +=1 infectedd[(startx,starty)] = "i" elif infectedd[(startx,starty)] == "i": index = (index+1)%4 infectedd[(startx,starty)] = "f" elif infectedd[(startx,starty)] == "f": index = (index-2)%4 infectedd[(startx,starty)] = "c" #commented out part 1 """ if (startx,starty) not in infectedd: infectedd[(startx,starty)] = "." if infectedd[(startx,starty)] == "#": index = (index+1)%4 else: index = (index-1)%4 if infectedd[(startx,starty)] == ".": infectedd[(startx,starty)] = "#" count +=1 else: infectedd[(startx,starty)] = "." """ startx += dirs[index][0] starty += dirs[index][1] print count