r/adventofcode • • Dec 08 '16

SOLUTION MEGATHREAD --- 2016 Day 8 Solutions ---

#AoC_Ops:

[23:55] <Topaz> servers are ok
[23:55] <Topaz> puzzles are checked
[23:55] <Topaz> [REDACTED: server stats]
[23:56] <Skie> all wings report in
[23:56] <Aneurysm9> Red 5, standing by
[23:56] <daggerdragon> Dragon Leader standing by
[23:56] <Topaz> orange leader, standing by
[23:57] <Topaz> lock modzi-foils in attack positions
[23:58] <Skie> we're passing through the hype field
[23:58] <daggerdragon> 1:30 warning
[23:58] <Aneurysm9> did someone say HYPE?@!
[23:59] <Topaz> i really like tonight's puzzle
[23:59] <Topaz> very excite
[23:59] <daggerdragon> final countdown go, T-30
[23:59] <Skie> accelerate to attack countdown
[23:59] <Aneurysm9> o7
[23:59] <daggerdragon> HYPE THRUSTERS AT FULL BURN
[00:00] <Topaz> IGNITION

We may or may not be sleep-deprived. And/or nerds. why_not_both.jpg


--- Day 8: Two-Factor Authentication ---

Post your solution as a comment or, for longer solutions, consider linking to your repo (e.g. GitHub/gists/Pastebin/blag/whatever).


:(){ :|:& };: IS MANDATORY [?]

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!

10 Upvotes

197 comments sorted by

View all comments

Show parent comment

2

u/TheRealEdwardAbbey Dec 08 '16

I learned today that Array(6).fill(Array(50).fill(0)) won't work - it fills the parent array with instances of the same child, so manipulating any row would manipulate all the rows. But I rotated the rows with row = row.slice(-dist).concat(row(0, -dist)), effectively un-linking that row from the others. That meant that only the first few fills were messed up, and my result for part 1 was only three short. Really threw me off...

Anyway, here's mine.

0

u/[deleted] Dec 08 '16

[deleted] — view deleted comment

1

u/TheRealEdwardAbbey Dec 08 '16

Yes, yes! That's excellent, thank you!

1

u/snorkl-the-dolphine Dec 08 '16

Very clever! I figured when I was writing the rotation code that it wasn't the best way of doing it, but I just needed to get something there to make it onto the leaderboard :)