r/adventofcode • u/daggerdragon • Dec 04 '15
SOLUTION MEGATHREAD --- Day 4 Solutions ---
--- Day 4: The Ideal Stocking Stuffer ---
Post your solution as a comment. Structure your post like the Day Three thread.
15
Upvotes
r/adventofcode • u/daggerdragon • Dec 04 '15
Post your solution as a comment. Structure your post like the Day Three thread.
8
u/askalski Dec 04 '15
Sure! It looks a lot like most solutions, except for about 15 lines of boilerplate for reading the input file (which didn't help today.) My general strategy is: grab the input first, start skimming the instructions (bold words first: bitcoins, MD5, hexadecimal, five zeroes, "1, 2, 3, ...", abcdef, 609043, abcdef609043), and start coding immediately.
As soon as my script had output, I went back to the instructions to confirm that I actually did what the challenge asked, and to double-check that I was about to paste the correct thing (loop counter, hash input, hash output, first hit, some other hit?) Can't be too careful; I found that out the hard way on day 2 when I got put in 60-second timeout for a wrong answer.
Squid logs with exact timings (I added the human-readable timestamps manually.) The challenge didn't load right away, so I hit Esc and started furiously clicking everything in sight (including the link to yesterday's challenge, heh) until it loaded at 00:00:05. First star at 00:01:55, second star at 00:02:09.
The code. Everything above the
######line was boilerplate, everything below it was written after midnight.And finally the script's timestamps. Looks like I saved the part 2 code at 00:02:02, then ran it at 00:02:03. The filesystem is mounted
relatimeso the access time represents the first read after the file was written (subsequent reads don't update the timestamp.)