32 lines
464 B
Python
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()
|