Exemple #1
0
        public void Run()
        {
            var positions = GetInputPositions().ToArray();

            Console.Out.WriteLine($"Part 1: {Part1.Run(positions)}");
            Console.Out.WriteLine($"Part 2: {Part2.Run(positions)}");
        }
Exemple #2
0
        private static void Main()
        {
            var input = System.IO.File.ReadAllLines("Input.txt");

            Console.WriteLine($"Day 2 :: Part 1 - {Part1.Calculate(input)}");
            Console.WriteLine($"Day 2 :: Part 2 - {Part2.Calculate(input)}");
        }
        static void Main(string[] args)
        {
            var      filename = "input.txt";
            IDayPart part1    = new Part1(filename);

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

            var part2 = new Part2(filename);

            part2.Solve();
            Console.WriteLine($"Part 2 result: {part2.Result}");
        }
Exemple #4
0
        static async Task Main(string[] args)
        {
            var input = (await File.ReadAllLinesAsync("input.txt"))[0];

            var part1         = new Part1();
            var part1Solution = part1.Solve(input, 12, 2);

            Console.WriteLine("Part1: " + part1Solution);

            var part2         = new Part2();
            var part2Solution = part2.GetNounAndVerb(input, 19690720);

            Console.WriteLine("Part2: " + part2Solution);

            Console.ReadLine();
        }
        public override int Execute(CommandContext context, Settings settings)
        {
            if (!File.Exists(settings.Input))
            {
                throw new InvalidOperationException("Input file do not exist.");
            }

            var source = File.ReadAllText(settings.Input);

            switch (settings.Part)
            {
            case 1: Part1.Run(source); break;

            case 2: Part2.Run(source); break;

            default:
                throw new InvalidOperationException("Unknown part number.");
            }

            return(0);
        }
Exemple #6
0
        static void PartTwo()
        {
            Part2.createKeypad();

            foreach (string line in File.ReadLines("../../input.txt"))
            {
                foreach (char c in line)
                {
                    Part2.checkBounds(c);
                    Console.WriteLine("Move " + c + " to " + Part2.keypad[Part2.currPos.Item2, Part2.currPos.Item1]);
                }
                Part2.combination.Add(Part2.keypad[Part2.currPos.Item2, Part2.currPos.Item1]);
            }

            Console.WriteLine("---------------");
            Console.WriteLine("Combination is: ");
            foreach (char c in Part2.combination)
            {
                Console.Write(c);
            }
            Console.Read();
        }