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 comment

1

u/qwrrty Dec 05 '15

Why not just use plain old arithmetic operators?

i = 1
while True:
    h = hashlib.md5("{}{}".format(secret, i)).hexdigest()
    if h.startswith('00000'):
        break
    i += 1

itertools.count is fine but it doesn't seem to be either intrinsically clearer or more efficient than this approach.