예제 #1
0
        public int GetuOutput(string path, int input)
        {
            Day2InputReader day2InputReader = new Day2InputReader();

            int[] fileContent = day2InputReader.ReadArray(path, ',');
            return(IntCode(fileContent, input));
        }
예제 #2
0
        public int GetNounVerbCombination(string path, int expectedResult)
        {
            Day2InputReader inputReader = new Day2InputReader();

            int[] originalInput = inputReader.ReadArray(path, ',');
            int[] input         = new int[originalInput.Length];

            for (int i = 0; i < input.Length; i++)
            {
                for (int j = 0; j <= i; j++)
                {
                    input = CloneOriginalInput(originalInput);
                    int result = CalculatePositionAtZero(input, i, j);
                    if (result == expectedResult)
                    {
                        return(100 * i + j);
                    }

                    if (i != j)
                    {
                        input  = CloneOriginalInput(originalInput);
                        result = CalculatePositionAtZero(input, j, i);
                        if (result == expectedResult)
                        {
                            return(100 * j + i);
                        }
                    }
                }
            }

            return(0);
        }
예제 #3
0
        public int GetPositionAtZero(string path, int?overwrite1, int?overwrite2)
        {
            Day2InputReader inputReader = new Day2InputReader();

            int[] input = inputReader.ReadArray(path, ',');

            return(CalculatePositionAtZero(input, overwrite1, overwrite2));
        }