Example #1
0
 private void doPainting()
 {
     while (!computer.hasStopped)
     {
         input.Add(getInput());
         computer.executeProgram(input, RunMode.BREAK_ON_OUTPUT);
         paintVisitedPanel(computer.getDiagnosticCode());
         computer.executeProgram(input, RunMode.BREAK_ON_OUTPUT);
         changeDirection(computer.getDiagnosticCode());
         changePosition();
         input = new List <int> {
             0
         };
     }
 }
Example #2
0
        override public void part1()
        {
            List <string> numberPermutations = StringUtils.permute("01234", 0, 4);
            int           result             = 0;

            foreach (string perm in numberPermutations)
            {
                int        local  = 0;
                List <int> phases = createPhases(perm);
                for (int i = 0; i < 5; i++)
                {
                    IntcodeComputer computer = new IntcodeComputer();
                    computer.loadProgramInput(7);
                    computer.createProgramFromInput();
                    computer.executeProgram(new List <int> {
                        phases[i], local
                    });
                    local = (int)computer.getDiagnosticCode();
                }
                if (local > result)
                {
                    result = local;
                }
            }
            System.Console.WriteLine("Day 7. Solution1 Expected:277328");
            System.Console.WriteLine("Day 7. Solution1:" + result.ToString());
        }
Example #3
0
        override public void part1()
        {
            Dictionary <string, long> board    = new Dictionary <string, long>();
            IntcodeComputer           computer = new IntcodeComputer();

            computer.loadProgramInput(13);
            computer.createProgramFromInput();
            while (!computer.hasStopped)
            {
                long x      = computer.executeProgram(null, RunMode.BREAK_ON_OUTPUT);
                long y      = computer.executeProgram(null, RunMode.BREAK_ON_OUTPUT);
                long tileId = computer.executeProgram(null, RunMode.BREAK_ON_OUTPUT);
                tileId = computer.getDiagnosticCode();
                if (!board.ContainsKey(x.ToString() + ',' + y.ToString()))
                {
                    board.Add(x.ToString() + ',' + y.ToString(), tileId);
                }
                else
                {
                    board[x.ToString() + ',' + y.ToString()] = tileId;
                }
            }
            int result = 0;

            foreach (int i in board.Values)
            {
                if (i == 2)
                {
                    result++;
                }
            }
            System.Console.WriteLine("Day 13. Solution1:" + result.ToString());
        }
Example #4
0
        override public void part1()
        {
            IntcodeComputer computer = new IntcodeComputer();
            List <int>      l        = new List <int>();

            l.Add(1);
            computer.loadProgramInput(5);
            computer.createProgramFromInput();
            computer.executeProgram(l);
            System.Console.WriteLine("Day 5. Solution1 expected: 12234644");
            System.Console.WriteLine("Day 5. Solution1:" + computer.getDiagnosticCode().ToString());
        }
Example #5
0
        override public void part1()
        {
            IntcodeComputer computer = new IntcodeComputer();

            computer.loadProgramInput(9);
            computer.createProgramFromInput();
            computer.executeProgram(new List <int> {
                1
            });
            long local = computer.getDiagnosticCode();

            System.Console.WriteLine("Day 9. Solution1:" + local.ToString());
        }