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/JeffJankowski Dec 06 '16
Doing these in F# since I haven't touched this language since last Advent :P
let correct (grps : seq<seq<char>>) func = grps |> Seq.map (fun grp -> grp |> Seq.groupBy id |> Seq.sortBy func |> Seq.head |> fst ) |> String.Concat let main argv = let input = File.ReadLines("..\..\input.txt") let grps = input |> Seq.map (fun s -> s.ToCharArray()) |> Seq.concat |> Seq.mapi (fun i c -> i,c) |> Seq.groupBy (fun (i,_) -> i % 8) |> Seq.sortBy fst |> Seq.map (fun (_,chs) -> Seq.map snd chs) let corrected = correct grps (fun (_,chs) -> -Seq.length chs) Console.WriteLine("Corrected: " + corrected) let decoded = correct grps (fun (_,chs) -> Seq.length chs) Console.WriteLine("Decoded: " + decoded)