Add code for 2015 advent that I did historically.
This commit is contained in:
parent
13968ed94e
commit
9e9e556c73
25 changed files with 598 additions and 0 deletions
19
day_4/solution.py
Normal file
19
day_4/solution.py
Normal file
|
|
@ -0,0 +1,19 @@
|
|||
import hashlib
|
||||
|
||||
passkey = input("Input passkey here: ")
|
||||
|
||||
|
||||
def find_suffix(passkey, leading_zeroes):
|
||||
hexkey = ""
|
||||
suffix = 0
|
||||
|
||||
while hexkey[:leading_zeroes] != "0" * leading_zeroes:
|
||||
suffix += 1
|
||||
hashkey = hashlib.md5(f"{passkey}{suffix}".encode())
|
||||
hexkey = hashkey.hexdigest()
|
||||
|
||||
return suffix
|
||||
|
||||
|
||||
print(f"Part 1 Suffix = {find_suffix(passkey, 5)}")
|
||||
print(f"Part 2 Suffix = {find_suffix(passkey, 6)}")
|
||||
Loading…
Add table
Add a link
Reference in a new issue