Beispiel #1
0
        public static void Main(string[] args)
        {
            Tuple <int, int> slope = new Tuple <int, int>(3, 1);

            SquareReader reader = new SquareReader(inputFile);

            reader.PopulateDb();
            Console.WriteLine($"Part 1 -> Answer: {Traverse(reader, slope)}");

            Tuple <int, int>[] slopes = new Tuple <int, int>[] {
                new Tuple <int, int>(1, 1),
                new Tuple <int, int>(3, 1),
                new Tuple <int, int>(5, 1),
                new Tuple <int, int>(7, 1),
                new Tuple <int, int>(1, 2)
            };

            long product = 1;

            foreach (Tuple <int, int> item in slopes)
            {
                reader.Reset();
                product *= Traverse(reader, item);
            }
            Console.WriteLine($"Part 2 -> Answer: {product}");
        }
Beispiel #2
0
        private static int Traverse(SquareReader reader, Tuple <int, int> slope)
        {
            char?character;
            int  counter = 0;

            while ((character = reader.NextCharacter(slope)) != null)
            {
                if (character == '#')
                {
                    counter++;
                }
                //Console.WriteLine(character);
            }

            return(counter);
        }