mirror of
https://github.com/Xevion/advent-of-code.git
synced 2025-12-07 09:14:22 -06:00
properly finish 2015 day 4 part 1 & part 2
This commit is contained in:
@@ -4,13 +4,20 @@ import sys
|
|||||||
import hashlib
|
import hashlib
|
||||||
|
|
||||||
PATH = os.path.join(sys.path[0], '..', 'input')
|
PATH = os.path.join(sys.path[0], '..', 'input')
|
||||||
SALT = 'bgvyzdsv'
|
SALT = open(PATH).read()
|
||||||
md5 = hashlib.md5()
|
md5_original = hashlib.md5(SALT.encode())
|
||||||
|
|
||||||
i = 0
|
|
||||||
while True:
|
def find_key(START_WITH):
|
||||||
md5.update((SALT + str(i)).encode())
|
i = 0
|
||||||
if md5.hexdigest().startswith('00000'):
|
while True:
|
||||||
|
md5 = md5_original.copy()
|
||||||
|
md5.update(str(i).encode())
|
||||||
|
md5hash = md5.hexdigest()
|
||||||
|
if md5hash.startswith(START_WITH):
|
||||||
print(i)
|
print(i)
|
||||||
break
|
break
|
||||||
i += 1
|
i += 1
|
||||||
|
|
||||||
|
find_key('00000')
|
||||||
|
find_key('000000')
|
||||||
Reference in New Issue
Block a user