public void Task1_Input_006()
        {
            var stringInput = @".";

            var number = Puzzle11.Task1(stringInput.ToPuzzle11Input());

            Assert.Equal(0, number);
        }
        public void Task1_Input_005()
        {
            var stringInput = @"LLL
LL.
LLL";

            var number = Puzzle11.Task1(stringInput.ToPuzzle11Input());

            Assert.Equal(4, number);
        }
示例#3
0
        private static void Main(string[] args)
        {
            var watch   = System.Diagnostics.Stopwatch.StartNew();
            var result1 = Puzzle11.Task1(PuzzleInput.ToPuzzle11Input());

            watch.Stop();
            var elapsedMs = watch.ElapsedMilliseconds;

            Console.WriteLine($"Element: {result1} (elapsed: {elapsedMs})");

            watch = System.Diagnostics.Stopwatch.StartNew();
            var result2 = Puzzle11.Task2(PuzzleInput.ToPuzzle11Input());

            watch.Stop();
            elapsedMs = watch.ElapsedMilliseconds;
            Console.WriteLine($"Element: {result2} (elapsed: {elapsedMs})");
        }
        public void Task2_Element()
        {
            var stringInput = @"L.LL.LL.LL
LLLLLLL.LL
L.L.L..L..
LLLL.LL.LL
L.LL.LL.LL
L.LLLLL.LL
..L.L.....
LLLLLLLLLL
L.LLLLLL.L
L.LLLLL.LL";

            var number = Puzzle11.Task2(stringInput.ToPuzzle11Input());

            Assert.Equal(26, number);
        }
示例#5
0
        private static void StartPuzzle(int puzzle)
        {
            switch (puzzle)
            {
            case 1:
                Console.WriteLine("Puzzle 1 solutions");
                Console.WriteLine("Part 1 sum is: " + Puzzle1.SolvePart1(PuzzleResources.Puzzle1));
                Console.WriteLine("Part 2 sum is: " + Puzzle1.SolvePart2(PuzzleResources.Puzzle1));
                break;

            case 2:
                Console.WriteLine("Puzzle 2 solutions");
                Console.WriteLine("Part 1 sum is: " + Puzzle2.SolvePart1(PuzzleResources.Puzzle2));
                Console.WriteLine("Part 2 sum is: " + Puzzle2.SolvePart2(PuzzleResources.Puzzle2));
                break;

            case 3:
                Console.WriteLine("Puzzle 3 solutions");
                Console.WriteLine("Part 1 sum is: " + Puzzle3.SolvePart1(PuzzleResources.Puzzle3));
                Console.WriteLine("Part 2 sum is: " + Puzzle3.SolvePart2(PuzzleResources.Puzzle3));
                break;

            case 4:
                Console.WriteLine("Puzzle 4 solutions");
                Console.WriteLine("Part 1 count is: " + Puzzle4.SolvePart1());
                Console.WriteLine("Part 2 count is: " + Puzzle4.SolvePart2());
                break;

            case 5:
                Console.WriteLine("Puzzle 5 solutions");
                Console.WriteLine("Part 1 stepcount is: " + Puzzle5.SolvePart1(PuzzleResources.Puzzle5));
                Console.WriteLine("Part 2 stepcount is: " + Puzzle5.SolvePart2(PuzzleResources.Puzzle5));
                break;

            case 6:
                Console.WriteLine("Puzzle 6 solutions");
                Console.WriteLine("Part 1 stepcount is: " + Puzzle6.SolveParts(PuzzleResources.Puzzle6, false));
                Console.WriteLine("Part 2 stepcount is: " + Puzzle6.SolveParts(PuzzleResources.Puzzle6, true));
                break;

            case 7:
                Console.WriteLine("Puzzle 7 solutions");
                Console.WriteLine("Part 1 stepcount is: " + Puzzle7.Solve1());
                Console.WriteLine("Part 2 stepcount is: " + Puzzle7.Solve2());
                break;

            case 8:
                Console.WriteLine("Puzzle 8 solutions");
                Console.WriteLine("Part 1 max value is: " + Puzzle8.Solve(false));
                Console.WriteLine("Part 2 max value is: " + Puzzle8.Solve(true));
                break;

            case 9:
                Console.WriteLine("Puzzle 9 solutions");
                Console.WriteLine("Part 1 groupcount is: " + Puzzle9.Solve(PuzzleResources.Puzzle9, false));
                Console.WriteLine("Part 2 count is: " + Puzzle9.Solve(PuzzleResources.Puzzle9, true));
                break;

            case 10:
                Console.WriteLine("Puzzle 10 solutions");
                Console.WriteLine("Part 1 multiply result is: " + Puzzle10.Solve(PuzzleResources.Puzzle10, 256, false));
                Console.WriteLine("Part 2 count is: " + Puzzle10.Solve(PuzzleResources.Puzzle10, 256, true));
                break;

            case 11:
                Console.WriteLine("Puzzle 11 solutions");
                Console.WriteLine("Part 1 steps is: " + Puzzle11.Solve(PuzzleResources.Puzzle11, false));
                Console.WriteLine("Part 2 max steps is: " + Puzzle11.Solve(PuzzleResources.Puzzle11, true));
                break;

            case 12:
                Console.WriteLine("Puzzle 12 solutions");
                Console.WriteLine("Part 1 count is: " + Puzzle12.Solve(new List <int>()
                {
                    0
                }, false));
                Console.WriteLine("Part 1 count is: " + Puzzle12.Solve(new List <int>()
                {
                    0
                }, false));
                break;

            case 13:
                Console.WriteLine("Puzzle 13 solutions");
                Console.WriteLine("Part 1 severity is: " + Puzzle13.Solve1(PuzzleResources.Puzzle13));
                Console.WriteLine("Part 1 required delay is: " + Puzzle13.Solve2(PuzzleResources.Puzzle13));
                break;
            }
        }
示例#6
0
        private static void PlayPuzzle()
        {
            Console.WriteLine("Which puzzle do you want to play?");
            var input = Console.ReadLine();

            Console.ForegroundColor = ConsoleColor.Cyan;;
            switch (input)
            {
            case "1":
                var input1 = File.ReadAllText("Inputs/Puzzle01.txt");
                Console.WriteLine($"Puzzle 1A answer is {Puzzle1.Part1(input1)}");
                Console.WriteLine($"Puzzle 1B answer is {Puzzle1.Part2(input1)}");
                break;

            case "2":
                var input2 = File.ReadAllLines("Inputs/Puzzle02.txt");
                Console.WriteLine($"Puzzle 2A answer is {Puzzle2.Part1(input2)}");
                Console.WriteLine($"Puzzle 2B answer is {Puzzle2.Part2(input2)}");
                break;

            case "3":
                var input3 = 325489;
                Console.WriteLine($"Puzzle 3A answer is {Puzzle3.Part1(input3)}");
                Console.WriteLine($"Puzzle 3B answer is {Puzzle3.Part2(input3)}");
                break;

            case "4":
                var input4 = File.ReadAllLines("Inputs/Puzzle04.txt");
                Console.WriteLine($"Puzzle 4A answer is {Puzzle4.Part1(input4)}");
                Console.WriteLine($"Puzzle 4B answer is {Puzzle4.Part2(input4)}");
                break;

            case "5":
                var input5 = File.ReadAllLines("Inputs/Puzzle05.txt");
                Console.WriteLine($"Puzzle 4A answer is {Puzzle5.Part1(input5)}");
                Console.WriteLine($"Puzzle 4B answer is {Puzzle5.Part2(input5)}");
                break;

            case "6":
                var input6 = File.ReadAllText("Inputs/Puzzle06.txt");
                Console.WriteLine($"Puzzle 6A answer is {Puzzle6.Part1(input6)}");
                Console.WriteLine($"Puzzle 6B answer is {Puzzle6.Part2(input6)}");
                break;

            case "7":
                var input7 = File.ReadAllLines("Inputs/Puzzle07.txt");
                Console.WriteLine($"Puzzle 7A answer is {Puzzle7.Part1(input7)}");
                Console.WriteLine($"Puzzle 7B answer is {Puzzle7.Part2(input7)}");
                break;

            case "8":
                var input8 = File.ReadAllLines("Inputs/Puzzle08.txt");
                Console.WriteLine($"Puzzle 8A answer is {Puzzle8.Part1(input8)}");
                Console.WriteLine($"Puzzle 8B answer is {Puzzle8.Part2(input8)}");
                break;

            case "9":
                var input9 = File.ReadAllText("Inputs/Puzzle09.txt");
                Console.WriteLine($"Puzzle 9A answer is {Puzzle9.Part1(input9)}");
                Console.WriteLine($"Puzzle 9B answer is {Puzzle9.Part2(input9)}");
                break;

            case "10":
                var input10 = File.ReadAllText("Inputs/Puzzle10.txt");
                Console.WriteLine($"Puzzle 10A answer is {Puzzle10.Part1(input10)}");
                Console.WriteLine($"Puzzle 10B answer is {Puzzle10.Part2(input10)}");
                break;

            case "11":
                var input11 = File.ReadAllText("Inputs/Puzzle11.txt");
                Console.WriteLine($"Puzzle 11A answer is {Puzzle11.Part1(input11)}");
                Console.WriteLine($"Puzzle 11B answer is {Puzzle11.Part2(input11)}");
                break;

            case "12":
                var input12 = File.ReadAllLines("Inputs/Puzzle12.txt");
                Console.WriteLine($"Puzzle 12A answer is {Puzzle12.Part1(input12)}");
                Console.WriteLine($"Puzzle 12B answer is {Puzzle12.Part2(input12)}");
                break;

            case "13":
                var input13 = File.ReadAllLines("Inputs/Puzzle13.txt");
                Console.WriteLine($"Puzzle 13A answer is {Puzzle13.Part1(input13)}");
                Console.WriteLine($"Puzzle 13B answer is {Puzzle13.Part2(input13)}");
                break;

            case "14":
                var input14 = File.ReadAllText("Inputs/Puzzle14.txt");
                Console.WriteLine($"Puzzle 14A answer is {Puzzle14.Part1(input14)}");
                Console.WriteLine($"Puzzle 14B answer is {Puzzle14.Part2(input14)}");
                break;

            case "15":
                var input15 = File.ReadAllLines("Inputs/Puzzle15.txt");
                Console.WriteLine($"Puzzle 15A answer is {Puzzle15.Part1(input15)}");
                Console.WriteLine($"Puzzle 15B answer is {Puzzle15.Part2(input15)}");
                break;

            case "16":
                var input16 = File.ReadAllText("Inputs/Puzzle16.txt");
                Console.WriteLine($"Puzzle 16A answer is {Puzzle16.Part1(input16)}");
                Console.WriteLine($"Puzzle 16B answer is {Puzzle16.Part2(input16)}");
                break;

            case "17":
                var input17 = File.ReadAllText("Inputs/Puzzle17.txt");
                Console.WriteLine($"Puzzle 17A answer is {Puzzle17.Part1(input17)}");
                Console.WriteLine($"Puzzle 17B answer is {Puzzle17.Part2(input17)}");
                break;

            case "18":
                var input18 = File.ReadAllLines("Inputs/Puzzle18.txt");
                Console.WriteLine($"Puzzle 18A answer is {Puzzle18.Part1(input18)}");
                Console.WriteLine($"Puzzle 18B answer is {Puzzle18.Part2(input18)}");
                break;

            case "19":
                var input19 = File.ReadAllLines("Inputs/Puzzle19.txt");
                Console.WriteLine($"Puzzle 19A answer is {Puzzle19.Part1(input19)}");
                Console.WriteLine($"Puzzle 19B answer is {Puzzle19.Part2(input19)}");
                break;

            case "20":
                var input20 = File.ReadAllLines("Inputs/Puzzle20.txt");
                Console.WriteLine($"Puzzle 20A answer is {Puzzle20.Part1(input20)}");
                Console.WriteLine($"Puzzle 20B answer is {Puzzle20.Part2(input20)}");
                break;

            case "21":
                var input21 = File.ReadAllLines("Inputs/Puzzle21.txt");
                Console.WriteLine($"Puzzle 21A answer is {Puzzle21.Part1(input21)}");
                Console.WriteLine($"Puzzle 21B answer is {Puzzle21.Part2(input21)}");
                break;

            case "22":
                var input22 = File.ReadAllLines("Inputs/Puzzle22.txt");
                Console.WriteLine($"Puzzle 22A answer is {Puzzle22.Part1(input22)}");
                Console.WriteLine($"Puzzle 22B answer is {Puzzle22.Part2(input22)}");
                break;

            case "23":
                var input23 = File.ReadAllLines("Inputs/Puzzle23.txt");
                Console.WriteLine($"Puzzle 23A answer is {Puzzle23.Part1(input23)}");
                Console.WriteLine($"Puzzle 23B answer is {Puzzle23.Part2(input23)}");
                break;

            case "24":
                var input24 = File.ReadAllLines("Inputs/Puzzle24.txt");
                Console.WriteLine($"Puzzle 24A answer is {Puzzle24.Part1(input24)}");
                Console.WriteLine($"Puzzle 24B answer is {Puzzle24.Part2(input24)}");
                break;

            case "25":
                Console.WriteLine($"Puzzle 25A answer is {Puzzle25.Part1()}");
                break;

            default:
                throw new NotImplementedException("That puzzle is not available yet");
            }
            Console.ForegroundColor = ConsoleColor.White;
        }