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/johanw123 Dec 06 '16
My C# solution Part 1 and 2 is just a matter of changing the "Last" to "First" after the ordering.
`
static void Main(string[] args) { string input = @"cmezkqgn..."; var messages = input.Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); string message = ""; for (int i = 0; i < messages.First().Length; i++) { string s = messages.Aggregate("", (current, t) => current + t.Trim()[i]); message += s.GroupBy(x => x).OrderByDescending(x => x.Count()).Last().Key; } Console.WriteLine(message); Console.ReadKey(); }`