Exemplo n.º 1
0
        private static void Main(string[] args)
        {
            Map       map         = new Map(@"./input.txt");
            Generator generator11 = new Generator(1, 1);
            Generator generator31 = new Generator(3, 1);
            Generator generator51 = new Generator(5, 1);
            Generator generator71 = new Generator(7, 1);
            Generator generator12 = new Generator(1, 2);

            TreeCounter treeCounter11 = new TreeCounter(map, generator11);
            TreeCounter treeCounter31 = new TreeCounter(map, generator31);
            TreeCounter treeCounter51 = new TreeCounter(map, generator51);
            TreeCounter treeCounter71 = new TreeCounter(map, generator71);
            TreeCounter treeCounter12 = new TreeCounter(map, generator12);

            long trees11 = treeCounter11.CountTrees();
            long trees31 = treeCounter31.CountTrees();
            long trees51 = treeCounter51.CountTrees();
            long trees71 = treeCounter71.CountTrees();
            long trees12 = treeCounter12.CountTrees();

            Console.WriteLine($"Found (1,1) {trees11} trees.");
            Console.WriteLine($"Found (3,1) {trees31} trees.");
            Console.WriteLine($"Found (5,1) {trees51} trees.");
            Console.WriteLine($"Found (7,1) {trees71} trees.");
            Console.WriteLine($"Found (1,2) {trees12} trees.");

            Console.WriteLine($"If you multiply all, you will get {trees11 * trees31 * trees51 * trees71 * trees12}.");
        }
Exemplo n.º 2
0
        static void Main(string[] args)
        {
            var counter = new TreeCounter("Input.txt");
            int part1   = counter.CountTrees(3, 1);

            Console.WriteLine($"Part 1: {part1}");

            int part2 = counter.CountTrees(1, 1) *
                        part1 *
                        counter.CountTrees(5, 1) *
                        counter.CountTrees(7, 1) *
                        counter.CountTrees(1, 2);

            Console.WriteLine($"Part 2: {part2}");
        }