Ejemplo n.º 1
0
        private static async Task Part2()
        {
            Console.CursorVisible = false;
            Console.ReadKey();

            var program = File.ReadAllText("input.txt");

            program = "2" + program.Substring(1);

            ArcadeCabinet arcade = new ArcadeCabinet();

            arcade.ScoreChanged += (sender, l) =>
            {
                Console.SetCursorPosition(0, 0);
                Console.WriteLine($"Score: {arcade.Score}      ");
            };

            arcade.ScreenChanged          += (sender, screenDelta) => UpdateScreen(screenDelta);
            arcade.JoystickInputRequested += (sender, args) =>
                                             arcade.TapJoystick(Math.Sign(BallX - PaddleX));

            await arcade.ExecuteProgram(program);

            Console.ReadKey();
        }
Ejemplo n.º 2
0
        public static long Solve(IEnumerable <string> input, int quarters = 2)
        {
            var memory = input
                         .First()
                         .Split(new[] { ',' }, StringSplitOptions.RemoveEmptyEntries)
                         .Select(i => long.Parse(i, CultureInfo.InvariantCulture))
                         .ToArray();

            memory[0] = quarters;

            var cabinet = new ArcadeCabinet(memory);

            cabinet.RobotSlideShow();
            //cabinet.RobotPlay();
            //cabinet.UserPlay();

            return(cabinet.Screen.Score);
        }