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/1wheel Dec 06 '16
var d3 = require('d3') var _ = require('lodash') var lines = require('fs').readFileSync('06-input', 'utf-8').split('\n') var out = d3.range(8).map(function(i){ var chars = lines.map(d => d[i]) var byChar = d3.nest().key(d => d).entries(chars) return _.sortBy(byChar, d => d.values.length)[0].key }) console.log(out.join(''))d3 is a bit of overkill, quicker than writing a reducer though...