diff --git a/puzzles/Y2015/D4/p1.py b/puzzles/Y2015/D4/p1.py new file mode 100644 index 0000000..96d0a04 --- /dev/null +++ b/puzzles/Y2015/D4/p1.py @@ -0,0 +1,12 @@ +import hashlib +from typing import Any + + +def puzzle(input: str) -> Any: + input = input.strip() + i = 0 + while True: + hash_hex_string = hashlib.md5((input + str(i)).encode()).hexdigest() + if hash_hex_string[:5] == "00000": + return i + i += 1 diff --git a/puzzles/Y2015/D4/p2.py b/puzzles/Y2015/D4/p2.py new file mode 100644 index 0000000..845f58b --- /dev/null +++ b/puzzles/Y2015/D4/p2.py @@ -0,0 +1,12 @@ +import hashlib +from typing import Any + + +def puzzle(input: str) -> Any: + input = input.strip() + i = 0 + while True: + hash_hex_string = hashlib.md5((input + str(i)).encode()).hexdigest() + if hash_hex_string[:6] == "000000": + return i + i += 1