2015 day 4

This commit is contained in:
2024-12-11 22:30:01 +01:00
parent b0dbc98766
commit eaf873b458
4 changed files with 32 additions and 0 deletions

1
2015/day-4/input.txt Normal file
View File

@@ -0,0 +1 @@
bgvyzdsv

15
2015/day-4/part-1.py Normal file
View File

@@ -0,0 +1,15 @@
import os
import hashlib
file_path = os.path.join(os.path.dirname(__file__), "./input.txt")
# file_path = os.path.join(os.path.dirname(__file__), "./test-input.txt")
input = open(file_path).read().strip()
number = 0
while True:
result = hashlib.md5((input + str(number)).encode()).hexdigest()
if result.startswith("00000"):
print(number)
break
number += 1

15
2015/day-4/part-2.py Normal file
View File

@@ -0,0 +1,15 @@
import os
import hashlib
file_path = os.path.join(os.path.dirname(__file__), "./input.txt")
# file_path = os.path.join(os.path.dirname(__file__), "./test-input.txt")
input = open(file_path).read().strip()
number = 0
while True:
result = hashlib.md5((input + str(number)).encode()).hexdigest()
if result.startswith("000000"):
print(number)
break
number += 1

View File

@@ -0,0 +1 @@
abcdef