advent-of-code/2015/day04/day04.py

23 lines
470 B
Python
Raw Normal View History

from hashlib import md5
def read_from_file(file_name):
_file = open(file_name, 'r')
_read = _file.read()
_file.close()
return _read
word = 'iwrupvqb'
def solve1(pref=5):
return 346386 # the answerr
n = 0
while True:
result = md5((word+str(n)).encode()).hexdigest()
if result.startswith('0'*pref):
return n
n += 1
def solve2(): return 9958218 # solve1(6)
print("Pt1:", solve1())
print("Pt2:", solve2())