Solve 2016 days 4 and 5.
This commit is contained in:
30
2016/d5.py
Normal file
30
2016/d5.py
Normal file
@@ -0,0 +1,30 @@
|
||||
from lib import *
|
||||
import hashlib
|
||||
|
||||
second = True
|
||||
data = open(0).read().strip()
|
||||
|
||||
if second:
|
||||
p = [" " for _ in range(8)]
|
||||
for i in range(10**12):
|
||||
s = data + str(i)
|
||||
h = hashlib.md5(s.encode()).hexdigest()
|
||||
if h.startswith("0" * 5) and h[5] in "01234567":
|
||||
index = int(h[5])
|
||||
if p[index] == " ":
|
||||
p[index] = h[6]
|
||||
# print("\r" + "".join(p))
|
||||
if not " " in p:
|
||||
p = "".join(p)
|
||||
break
|
||||
else:
|
||||
p = ""
|
||||
for i in range(10**12):
|
||||
s = data + str(i)
|
||||
h = hashlib.md5(s.encode()).hexdigest()
|
||||
if h.startswith("0" * 5):
|
||||
p += h[5]
|
||||
if len(p) == 8:
|
||||
break
|
||||
|
||||
print(p)
|
||||
Reference in New Issue
Block a user