advent-of-code/2015/python/day04.py
2022-12-18 23:55:45 -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()