Artige oppgaver i Advent of Code.
Min for Advent of Code 5.
Kode
import hashlib
def hash_find():
hash_lst = []
i = 0
while len(hash_lst) < 8:
make = 'cxdnnyjw{}'.format(i)
i += 1
if hashlib.md5(str.encode(make)).hexdigest().startswith('00000'):
hash_lst.append(hashlib.md5(str.encode(make)).hexdigest())
return(hash_lst)
def password(hash_find):
print(''.join(i[5] for i in hash_find()))
if __name__ == '__main__':
password(hash_find)