private static void Move(Numpad numpad, AdvancedNumpad numpad2, char move) { switch (move) { case 'U': numpad.Up(); numpad2.Up(); break; case 'D': numpad.Down(); numpad2.Down(); break; case 'L': numpad.Left(); numpad2.Left(); break; case 'R': numpad.Right(); numpad2.Right(); break; } }
public static void Run() { Puzzle.Greet(Greeting); var inputs = File.ReadAllLines(Environment.CurrentDirectory + "/inputs/day2.txt").ToList(); var numpad = new Numpad() { X = 1, Y = 1 }; var numpad2 = new AdvancedNumpad { X = 0, Y = 2 }; var combination1 = ""; var combination2 = ""; inputs.ForEach(x => { x.ToCharArray().ToList().ForEach(c => Move(numpad, numpad2, c)); combination1 += numpad.Digit(); combination2 += numpad2.Digit(); }); Puzzle.Print($"The combination is: {combination1}", $"The combination is: {combination2}"); }