mirror of
https://github.com/ershisan99/advent-of-code.git
synced 2025-12-16 12:32:49 +00:00
2015 day 4
This commit is contained in:
1
2015/day-4/input.txt
Normal file
1
2015/day-4/input.txt
Normal file
@@ -0,0 +1 @@
|
|||||||
|
bgvyzdsv
|
||||||
15
2015/day-4/part-1.py
Normal file
15
2015/day-4/part-1.py
Normal 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
15
2015/day-4/part-2.py
Normal 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
|
||||||
1
2015/day-4/test-input.txt
Normal file
1
2015/day-4/test-input.txt
Normal file
@@ -0,0 +1 @@
|
|||||||
|
abcdef
|
||||||
Reference in New Issue
Block a user