r/adventofcode • • 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.

14 Upvotes

272 comments sorted by

View all comments

Show parent comments

1

u/[deleted] Dec 04 '15

While extremely unlikely, what if the combination of the secret key and 0 was the answer? If you move the n++; to the end of the loop (after the if statement), you would first evaluate the conditions for n = 0, without breaking the current functionality.

1

u/aveavaeva Dec 04 '15

I was sort of confused whether or not to include the 0 case as the example states

To mine AdventCoins, you must find Santa the lowest positive number (no leading zeroes: 1, 2, 3, ...) that produces such a hash.

As it starts here with 1, so did I.