[Python/2016] Move solutions into .py files
This commit is contained in:
parent
0269ad8fc3
commit
2514b1d11f
50 changed files with 1172 additions and 3386 deletions
27
Python/2016/05.py
Normal file
27
Python/2016/05.py
Normal file
|
@ -0,0 +1,27 @@
|
|||
from lib import *
|
||||
|
||||
input = read_input(2016, 5)
|
||||
|
||||
|
||||
out = ""
|
||||
i = 0
|
||||
while len(out) < 8:
|
||||
while not (digest := hashlib.md5(f"{input.strip()}{i}".encode()).hexdigest()).startswith("0" * 5):
|
||||
i += 1
|
||||
out += digest[5]
|
||||
i += 1
|
||||
|
||||
print(out)
|
||||
|
||||
|
||||
out = ["_"] * 8
|
||||
i = 0
|
||||
while "_" in out:
|
||||
while not (digest := hashlib.md5(f"{input.strip()}{i}".encode()).hexdigest()).startswith("0" * 5):
|
||||
i += 1
|
||||
i += 1
|
||||
if not "0" <= digest[5] <= "7" or out[(d := int(digest[5]))] != "_":
|
||||
continue
|
||||
out[d] = digest[6]
|
||||
|
||||
print("".join(out))
|
Loading…
Add table
Add a link
Reference in a new issue