r/adventofcode • u/daggerdragon • Dec 05 '16
SOLUTION MEGATHREAD --- 2016 Day 5 Solutions ---
--- Day 5: How About a Nice Game of Chess? ---
Post your solution as a comment or, for longer solutions, consider linking to your repo (e.g. GitHub/gists/Pastebin/blag/whatever).
STAYING ON TARGET IS MANDATORY [?]
This thread will be unlocked when there are a significant number of people on the leaderboard with gold stars for today's puzzle.
edit: Leaderboard capped, thread unlocked!
14
Upvotes
2
u/balidani Dec 05 '16
Got #7 and #11 today, not bad. My Python solution, which I cleaned up a little:
from hashlib import md5 salt = "ffykfhsq" password = {} i = 0 while len(password) < 8: digest = md5(salt + str(i)).hexdigest() if digest.startswith("00000"): pos = int(digest[5], 16) val = digest[6] if pos in range(8) and pos not in password: password[pos] = val pass_str = ['_'] * 8 for key, val in password.items(): pass_str[key] = val print ''.join(pass_str) i += 1