public void PartOne(string input, TextWriter @out) { var map = ScaffoldingInterface.Run(IntcodeParser.Parse(input)); PrintMap(map, @out); var intersections = FindIntersections(map); var alignment = intersections .Sum(point => point.X * point.Y); @out.WriteLine($"Sum of alignment parameters: {alignment}"); }
public void PartTwo(string input, TextWriter @out) { var program = IntcodeParser.Parse(input); var map = ScaffoldingInterface.Run(program); var actions = BuildPath(map); var(inputProgram, subsets) = CalculateSubsets(actions); @out.WriteLine($"Generated Path: {string.Join(",", actions)}"); @out.WriteLine($"Generated Program: {string.Join(",", inputProgram)}"); foreach (var subset in subsets) { @out.WriteLine($"Subset: {string.Join(",", subset)}"); } var updatedProgram = program.SetItem(0, 2); var dust = ScaffoldingInterface.RunWithInput(updatedProgram, inputProgram, subsets); @out.WriteLine($"Amount of dust collected by Robot is: {dust}"); }