Day 4, Year 2015: The Ideal Stocking Stuffer
First read the problem description.
import hashlib
def mine(key, zeros=5):
= key.encode()
key = 0
n = '0' * zeros
z while True:
+= 1
n = str(n).encode()
nb hex = hashlib.md5(key + nb).hexdigest()
if hex.startswith(z):
return n
assert mine('abcdef', 5) == 609043
assert mine('pqrstuv', 5) == 1048970
'yzbqklnj', 5) mine(
282749
'yzbqklnj', 6) mine(
9962624
Source code of the solution(s):