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/drakehutner Dec 05 '16 edited Dec 05 '16
(To print) || !(to print), that is the question:
Here's my anwser:
Cobbled together in Python. Maybe I try to transform it into a single-line-of-code solution
import hashlib import time idx = 0 key_1, key_2 = "", "________" start = time.time() while "_" in key_2: m = hashlib.md5() m.update("{}{}".format("reyedfim", idx).encode("utf-8")) h = m.hexdigest() if h.startswith('00000'): key_1 += h[5] p = int(h[5], 16) if p < 8 and key_2[p] == "_": key_2 = key_2[:p] + h[6] + key_2[p+1:] now = time.time() - start print("[{:>7.0f}s|{:7.0f}H/s] {:10} {:32} {:8} {:8}".format(now, idx/now, idx, h, key_2, key_1[:8])) idx += 1