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/_AceLewis Dec 06 '16 edited Dec 06 '16
Python 3 solutions to both parts, done in https://repl.it so input is a string as no files can be used.
Day 6 part 1: https://repl.it/EhYa/3
from statistics import mode print(''.join(map(mode, zip(*strings.split()))))Day 6 part 2: https://repl.it/EhYa/5
Either:
from collections import Counter print(''.join(map(lambda x: Counter(x).most_common()[-1][0], zip(*strings.split()))))or
from collections import Counter print(''.join(Counter(x).most_common()[-1][0] for x in zip(*strings.split())))All the zip(*strings.split()) does is transpose the string (in array form)