Ejemplo n.º 1
0
    public static int Part2(string inputText)
    {
        var program = new IntCodeProgram(InputParser.ListOfLongs(inputText, ','), 0, 0);
        var robot   = new EHPR(program);

        robot.Painting.Add(new Vector2Int(0, 0), new List <long>(new long[] { 1 }));
        robot.Run();

        AOCExecutor.ActionForMain.Enqueue(() => WriteToFilePainting(robot.Painting, "Day11_Part2.txt"));
        var bounds = MathUtils.FindBound(robot.Painting.Keys.ToList());
        int xOff   = -bounds.xMin;
        int yOff   = -bounds.yMin;

        Debug.Log(bounds);
        var image = new int[bounds.size.y + 1, bounds.size.x + 1];

        foreach (var pt in robot.Painting)
        {
            if (pt.Key.x < bounds.min.x || pt.Key.x > bounds.max.x || pt.Key.y < bounds.min.y || pt.Key.y > bounds.max.y)
            {
                Debug.Log($"Contains pas {pt.Key}");
            }
            if (pt.Value.Count == 0)
            {
                continue;
            }
            var value = pt.Value.Last();
            image[bounds.size.y - (pt.Key.y + yOff), pt.Key.x + xOff] = (int)value;
        }

        AOCExecutor.ActionForMain.Enqueue(() => Day8Main.ImageToTexturee(image, bounds.size.x + 1, bounds.size.y + 1, AOCUI.Instance.Part1ComputeOutput));

        return(2);
    }
Ejemplo n.º 2
0
    public static int Part1(string inputText)
    {
        var program = new IntCodeProgram(InputParser.ListOfLongs(inputText, ','), 0, 0);
        var robot   = new EHPR(program);

        robot.Run();

        return(robot.Painting.Count);
    }
Ejemplo n.º 3
0
        public void Part1()
        {
            var program = new IntCodeProgram(InputParser.ListOfLongs(Day11Input, ','), 0, 0);
            var robot   = new EHPR(program);

            robot.Run();

            WriteToFilePainting(robot.Painting, "D11_Part1.txt");

            Assert.AreEqual(1, robot.Painting.Count);
        }
Ejemplo n.º 4
0
        public void Part1_GoingRight_Step4()
        {
            var program = ProgramThatOutput(1, 1, 0, 1, 1, 1, 0, 1);
            var robot   = new EHPR(program);

            robot.Run();

            Assert.AreEqual(EHPR.Direction.UP, robot.CurrentDirection);
            Assert.AreEqual(new Vector2Int(0, 0), robot.CurrentPosition);
            Assert.AreEqual(0, robot.Painting[new Vector2Int(0, -1)].Last());
        }
Ejemplo n.º 5
0
        public void Part2()
        {
            var program = new IntCodeProgram(InputParser.ListOfLongs(Day11Input, ','), 0, 0);
            var robot   = new EHPR(program);

            robot.Painting.Add(new Vector2Int(0, 0), new List <long>(new long[] { 1 }));
            robot.Run();

            WriteToFilePainting(robot.Painting, "D11_Part2.txt");

            Assert.AreEqual(1, robot.Painting.Count);
        }
Ejemplo n.º 6
0
        public void Part1_Exemple1_Step6()
        {
            var program = ProgramThatOutput(1, 0, 0, 0, 1, 0, 1, 0, 0, 1, 1, 0);
            var robot   = new EHPR(program);

            robot.Run();

            PrintPainting(robot.Painting);
            var position     = new Vector2Int(1, 1);
            var lastPosition = new Vector2Int(1, 0);

            Assert.AreEqual(EHPR.Direction.UP, robot.CurrentDirection);
            Assert.AreEqual(position, robot.CurrentPosition);
            Assert.AreEqual(1, robot.Painting[lastPosition].Last());
        }