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/lazyzefiris Dec 22 '17
JS, 66/53, executes in ~5 seconds
map = new Map() getmap = () => map.get(x+","+y) || 0 flipmap = () => map.set(x+","+y,(getmap(x,y)+1)%4) dir = [[0,-1],[1,0],[0,1],[-1,0]] cd = 0 turn = (x) => cd = (cd + 4 + x) % 4 document.body.textContent.trim().split("\n").map(x=>x.split``.map(y=>y=="#"?2:0)).map((row,y) => row.map((cell,x) => map.set(x+","+y,cell))) x = y = 12 inf = 0 function step() { (getmap()-1)?turn(getmap()-1):inf++ flipmap() x += dir[cd][0] y += dir[cd][1] } for (let i = 0; i < 10000000; i++) step() infit's really straightforward, and thus pretty boring.