public override string SolvePart1() { // Build a list of two-way links PairLinkCollection pairs = ReadPairLinks(); return($"{MaxCircleValue(pairs)}"); }
private PairLinkCollection ReadPairLinks() { var pairs = new PairLinkCollection(); PairLink pairlink; foreach (string line in Input) { string[] words = line.Split(' '); int sign = (words[2] == "lose") ? -1 : 1; int value = Int32.Parse(words[3]); string person = words[0]; string other = words[^ 1].Substring(0, words[^ 1].Length - 1); // Remove full stop at the end
public override string SolvePart2() { // Build a list of two-way links PairLinkCollection pairs = ReadPairLinks(); // Add myself string[] people = pairs.Persons.ToArray(); // Copy the list first, because the loop will alter it foreach (string other in people) { pairs.Add(new PairLink("Myself", other, 0)); } return($"{MaxCircleValue(pairs)}"); }