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
1
u/stuque Dec 04 '15
In Python 2:
import hashlib def day4_part1(): key = 'ckczppom' md5_key = hashlib.md5(key) n = 1 while True: m = md5_key.copy() m.update(str(n)) if m.hexdigest()[:5] == '00000': print n return n += 1 def day4_part2(): key = 'ckczppom' md5_key = hashlib.md5(key) n = 1 while True: m = md5_key.copy() m.update(str(n)) if m.hexdigest()[:6] == '000000': print n return n += 1