advent-of-code/2015/day04.py
Tyrel Souza b2ad0448ba 2015
2022-12-09 16:41:14 -05:00

32 lines
464 B
Python

import hashlib
def hsh(st, ct=5):
return hashlib.md5(st.encode('utf-8')).hexdigest()[:ct] == ("0"*ct)
def pt1(seed):
idx = 0
while True:
idx +=1
if hsh(f"{seed}{idx}"):
break
print(idx)
def pt2(seed):
idx = 0
while True:
idx +=1
if hsh(f"{seed}{idx}", 6):
break
print(idx)
def main():
inp = "iwrupvqb"
pt1(inp)
pt2(inp)
if __name__ == "__main__":
main()