Exemplo n.º 1
0
        private int[] readImageDataFromInputfile()
        {
            string[]   fileLines = SantasLittleHelperClass.TextfileToStringArray(INPUT_FILE_PATH);
            string     input     = fileLines[0];
            List <int> numbers   = new List <int>();

            foreach (char c in input)
            {
                numbers.Add(int.Parse(c.ToString()));
            }
            return(numbers.ToArray());
        }
Exemplo n.º 2
0
        private void loadDirectionsFromFile()
        {
            string[]      input      = SantasLittleHelperClass.TextfileToStringArray(INPUT_FILE_PATH);
            List <string> directions = new List <string>();

            for (int i = 0; i < input.Length; i++)
            {
                directions.Add(input[i]);
            }

            wire1_dirs = directions.ToArray()[0].Split(',');
            wire2_dirs = directions.ToArray()[1].Split(',');
        }
Exemplo n.º 3
0
        public Day2()
        {
            string[]   fileLines = SantasLittleHelperClass.TextfileToStringArray(INPUT_FILE_PATH);
            List <int> program   = new List <int>();

            for (int i = 0; i < fileLines.Length; i++)
            {
                string[] split = fileLines[i].Split(',');
                for (int j = 0; j < split.Length; j++)
                {
                    program.Add(SantasLittleHelperClass.StringToInt(split[j]));
                }
            }
            originalMemory = program.ToArray();
        }
Exemplo n.º 4
0
        private int[] inputFileToIntArray()
        {
            string[]   fileLines = SantasLittleHelperClass.TextfileToStringArray(InputFilePath);
            List <int> program   = new List <int>();

            for (int i = 0; i < fileLines.Length; i++)
            {
                string[] split = fileLines[i].Split(',');
                for (int j = 0; j < split.Length; j++)
                {
                    program.Add(SantasLittleHelperClass.StringToInt(split[j]));
                }
            }
            return(program.ToArray());
        }
Exemplo n.º 5
0
        public int calcTotalFuelRequirement()
        {
            string[] fileLines = SantasLittleHelperClass.TextfileToStringArray(INPUT_FILE_PATH);
            int[]    masses    = new int[fileLines.Length];
            for (int i = 0; i < fileLines.Length; i++)
            {
                masses[i] = SantasLittleHelperClass.StringToInt(fileLines[i]);
            }
            int totalFuelReq = 0;

            for (int i = 0; i < masses.Length; i++)
            {
                totalFuelReq += calcFuel(masses[i]);
            }
            return(totalFuelReq);
        }
Exemplo n.º 6
0
 private string[] getCommandsFromFile()
 {
     return(SantasLittleHelperClass.TextfileToStringArray(INPUT_FILE_PATH));
 }