advent-of-code/src/holt59/aoc/2015/day4.py

17 lines
389 B
Python
Raw Normal View History

2024-01-04 20:05:42 +00:00
import hashlib
import itertools
import sys
line = sys.stdin.read().strip()
it = iter(itertools.count(1))
answer_1 = next(
i for i in it if hashlib.md5(f"{line}{i}".encode()).hexdigest().startswith("00000")
)
print(f"answer 1 is {answer_1}")
answer_2 = next(
i for i in it if hashlib.md5(f"{line}{i}".encode()).hexdigest().startswith("000000")
)
print(f"answer 2 is {answer_2}")