Add various uncommitted 2021 files for posterity

This commit is contained in:
Josh Creek
2022-10-12 18:28:43 +01:00
parent 3b3a25b9cd
commit fd8b8c7ef1
16 changed files with 848 additions and 18 deletions
+48
View File
@@ -56,12 +56,18 @@
string secondHalf = line.Substring(line.IndexOf("|") + 1);
List<string> numberSegments = secondHalf.Split(' ').ToList();
string lineTotal = string.Empty;
foreach (string numberSegment in numberSegments)
{
// Go through sorted in alphabetical order
string alphabetisedNumberSegment = String.Concat(numberSegment.OrderBy(c => c));
Console.WriteLine(alphabetisedNumberSegment);
if(alphabetisedNumberSegment == String.Concat("acedgfb".OrderBy(c => c)))
{
@@ -103,6 +109,8 @@
{
lineTotal += "1";
}
Console.WriteLine(lineTotal);
}
Console.WriteLine(lineTotal);
@@ -114,5 +122,45 @@
Console.WriteLine(total);
}
static Dictionary<int, string> DetermineMapping(string[] lines)
{
Dictionary<int, string> mapping = new Dictionary<int, string>();
foreach (string line in lines)
{
string secondHalf = line.Substring(line.IndexOf("|") + 1);
List<string> numberSegments = secondHalf.Split(' ').ToList();
foreach (string numberSegment in numberSegments)
{
switch (numberSegment.Length)
{
case 7:
// 8 has only 7 segments/letters
mapping.Add(8, numberSegment);
break;
case 3:
// 7 has only 3 segments/letters
mapping.Add(7, numberSegment);
break;
case 4:
// 4 has only 4 segments/letters
mapping.Add(4, numberSegment);
break;
case 2:
// 1 has only 2 segments/letters
mapping.Add(1, numberSegment);
break;
default:
// handle the non-unique lengths (0,2,3,5,6,9)
break;
}
}
}
return mapping;
}
}
}