Something is jamming your communications with Santa. Fortunately, your signal is only partially jammed, and protocol in situations like this is to switch to a simple repetition code to get the message through.
In this model, the same message is sent repeatedly. You've recorded the repeating message signal (your puzzle input), but the data seems quite corrupted - almost too badly to recover. Almost.
Read the full puzzle.
using System.Linq;
namespace AdventOfCode.Y2016.Day06;
[ProblemName("Signals and Noise")]
class Solution : Solver {
public object PartOne(string input) => Decode(input).mostFrequent;
public object PartTwo(string input) => Decode(input).leastFrequent;
(string mostFrequent, string leastFrequent) Decode(string input) {
var lines = input.Split('\n');
string mostFrequent = "";
string leastFrequent = "";
for (int i = 0; i < lines[0].Length; i++) {
var items = (from line in lines group line by line[i] into g orderby g.Count() select g.Key);
mostFrequent += items.Last();
leastFrequent += items.First();
}
return (mostFrequent: mostFrequent, leastFrequent: leastFrequent);
}
}
Please ☆ my repo if you like it!