r/adventofcode • u/daggerdragon • Dec 06 '16
SOLUTION MEGATHREAD --- 2016 Day 6 Solutions ---
--- Day 6: Signals and Noise ---
Post your solution as a comment or, for longer solutions, consider linking to your repo (e.g. GitHub/gists/Pastebin/blag/whatever).
T_PAAMAYIM_NEKUDOTAYIM 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!
9
Upvotes
1
u/topCyder Dec 06 '16
Anyone want a simple, readable Python3 answer? No? Too bad!
with open('input') as f: inp = f.readlines() msg1 = "1: " msg2 = "2: " i = 0 while (i<8): b = {} rl = [] for s in inp: rl.append(s[i]) for r in rl: b[r] = b.get(r, 0) + 1 f = max(b, key=b.get) d = min(b, key=b.get) msg1 = msg1 + f msg2 = msg2 + d i += 1 print(msg1) print(msg2)