2015 day 4, 5, 6, 7.

This commit is contained in:
Mikaël Capelle
2024-01-04 21:05:42 +01:00
parent 42bd8d6983
commit cd0ada785c
12 changed files with 1850 additions and 3 deletions

View File

@@ -0,0 +1,16 @@
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}")