Пример #1
0
        public void TestCountTilesOfType()
        {
            Arcade a = new Arcade(new long[1]);

            a.UpdateTile(new Point(0, 4), (int)Arcade.Tile.Wall);
            a.UpdateTile(new Point(1, 4), (int)Arcade.Tile.Wall);
            a.UpdateTile(new Point(2, 4), (int)Arcade.Tile.Wall);
            a.UpdateTile(new Point(3, 4), (int)Arcade.Tile.Empty);
            a.UpdateTile(new Point(4, 4), (int)Arcade.Tile.Empty);

            Assert.That(a.CountTilesOfType(Arcade.Tile.Wall), Is.EqualTo(3));
            Assert.That(a.CountTilesOfType(Arcade.Tile.Empty), Is.EqualTo(2));
            Assert.That(a.CountTilesOfType(Arcade.Tile.Ball), Is.EqualTo(0));
        }
Пример #2
0
        public string SolvePartOne(string[] input)
        {
            long[] game = string.Join(",", input)
                          .Split(",")
                          .Select(x => Int64.Parse(x))
                          .ToArray();
            Arcade arcade = new Arcade(game);

            Point p;
            int   tileId;

            do
            {
                p = new Point(0, 0);

                arcade.Run();
                p.X = (int)arcade.Output;

                arcade.Run();
                p.Y = (int)arcade.Output;

                arcade.Run();
                tileId = (int)arcade.Output;

                arcade.UpdateTile(p, tileId);
            } while (arcade.CurrentState != IntcodeComputer.State.Halted);

            return(arcade.CountTilesOfType(Arcade.Tile.Block).ToString());
        }