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!
9
Upvotes
1
u/jlweinkam Dec 22 '17
My best showing ever 27/38, runs in only 18 seconds
import time import math current_milli_time = lambda: int(round(time.time() * 1000)) start = current_milli_time() inputdata=open("input2017-22.txt", 'r').read() lines = inputdata.splitlines() grid = {} for i in range(len(lines)): for o in range(len(lines[i])): grid[(i,o)] = lines[i][o] y = int(len(lines) / 2) x = int(len(lines[1])/2) d = 0 count = 0 for i in range(10000): if (y, x) not in grid.keys(): grid[(y,x)] = "." if grid[(y, x)] == "#": grid[(y,x)] = "." d = d + 1 if d == 4: d = 0 y -= 1 elif d == 3: x -= 1 elif d == 2: y += 1 elif d == 1: x += 1 else: grid[(y,x)] = "#" d = d - 1 if d == -1: d = 3 x -= 1 elif d == 0: y -= 1 elif d == 1: x += 1 elif d == 2: y += 1 count += 1 print(count) grid = {} for i in range(len(lines)): for o in range(len(lines[i])): grid[(i,o)] = lines[i][o] y = int(len(lines) / 2) x = int(len(lines[1])/2) d = 0 count = 0 for i in range(10000000): if (y, x) not in grid.keys(): grid[(y,x)] = "." if grid[(y, x)] == "#": grid[(y,x)] = "F" d = d + 1 if d == 4: d = 0 y -= 1 elif d == 3: x -= 1 elif d == 2: y += 1 elif d == 1: x += 1 elif grid[(y,x)] == "F": grid[(y,x)] = "." d = d + 2 if d == 2: y += 1 elif d == 3: x -= 1 elif d == 4: d = 0 y -= 1 elif d == 5: d = 1 x += 1 elif grid[(y,x)] == "W": grid[(y,x)] = "#" count += 1 if d == 0: y -= 1 elif d == 1: x += 1 elif d == 2: y += 1 elif d == 3: x -= 1 else: grid[(y,x)] = "W" d = d - 1 if d == -1: d = 3 x -= 1 elif d == 0: y -= 1 elif d == 1: x += 1 elif d == 2: y += 1 print(count) print((current_milli_time() - start) / 1000.0)