advent/2015/4/sol.py
2022-11-06 13:55:53 -06:00

17 lines
371 B
Python

file = [i.rstrip() for i in open("input").readlines()]
import hashlib
key = file[0]
i = 1
while True:
output = hashlib.md5("{}{}".format(key, str(i)).encode())
digest = output.hexdigest()
# change from [0:6] to [0:5] for sol 1
if len(set(digest[0:6])) == 1 and digest[0] == '0':
# we've 'mined' a coin
print(i)
break
i += 1