Example #1
0
 static void Main(string[] args)
 {
     Day1.Process();
     Day2.Process();
     Day3.Process();
     Console.ReadKey();
 }
Example #2
0
        public void MovingToEmptySpace_StaysAtNumber()
        {
            Day2 day2 = new Day2();

            day2.SetupForPart2();
            Assert.AreEqual("5", day2.Solve(""));
            Assert.AreEqual("5", day2.Solve("U"));
            Assert.AreEqual("5", day2.Solve("D"));
        }
Example #3
0
        static void Main(string[] args)
        {
            Console.ForegroundColor = ConsoleColor.Green;
            Console.WriteLine("DAY 1");
            Console.ForegroundColor = ConsoleColor.White;
            Day1.Run();

            Console.ForegroundColor = ConsoleColor.Green;
            Console.WriteLine("DAY 2");
            Console.ForegroundColor = ConsoleColor.White;
            Day2.Run();

            Console.ForegroundColor = ConsoleColor.Green;
            Console.WriteLine("DAY 3");
            Console.ForegroundColor = ConsoleColor.White;
            Day3.Run();

            Console.ForegroundColor = ConsoleColor.Green;
            Console.WriteLine("DAY 4");
            Console.ForegroundColor = ConsoleColor.White;
            Day4.Run();

            Console.ForegroundColor = ConsoleColor.Green;
            Console.WriteLine("DAY 5 (May take a while!)");
            Console.ForegroundColor = ConsoleColor.White;
            Day5.Run();

            Console.ForegroundColor = ConsoleColor.Green;
            Console.WriteLine("DAY 6");
            Console.ForegroundColor = ConsoleColor.White;
            Day6.Run();

            Console.ForegroundColor = ConsoleColor.Green;
            Console.WriteLine("DAY 7");
            Console.ForegroundColor = ConsoleColor.White;
            Day7.Run();

            Console.ForegroundColor = ConsoleColor.Green;
            Console.WriteLine("DAY 8");
            Console.ForegroundColor = ConsoleColor.White;
            Day8 day8 = new Day8();

            day8.Run();

            Console.ForegroundColor = ConsoleColor.Green;
            Console.WriteLine("DAY 9");
            Console.ForegroundColor = ConsoleColor.White;
            Day9 day9 = new Day9();

            day9.Run();

            Console.ForegroundColor = ConsoleColor.Green;
            Console.WriteLine("DAY 10");
            Console.ForegroundColor = ConsoleColor.White;
            Day10.Run();
        }
Example #4
0
        public static void Main()
        {
            //Day1.Run (ReadFile("../../Day1/Day1Input.txt"));
            Day2 day2 = new Day2();

            day2.SetupForPart2();
            string answer = day2.Solve(ReadFile("../../Day2/Input.txt"));

            Console.WriteLine(answer);
        }
Example #5
0
        public void MovingDownOnBottomSide_StaysAtNumber()
        {
            Day2 day2 = new Day2();

            Assert.AreEqual("5", day2.Solve(""));
            Assert.AreEqual("8", day2.Solve("D"));
            Assert.AreEqual("8", day2.Solve("D"));
            Assert.AreEqual("7", day2.Solve("L"));
            Assert.AreEqual("7", day2.Solve("D"));
            Assert.AreEqual("9", day2.Solve("RR"));
            Assert.AreEqual("9", day2.Solve("D"));
        }
Example #6
0
        public void MovingUpOnTopSide_StaysAtNumber()
        {
            Day2 day2 = new Day2();

            Assert.AreEqual("5", day2.Solve(""));
            Assert.AreEqual("2", day2.Solve("U"));
            Assert.AreEqual("2", day2.Solve("U"));
            Assert.AreEqual("1", day2.Solve("L"));
            Assert.AreEqual("1", day2.Solve("U"));
            Assert.AreEqual("3", day2.Solve("RR"));
            Assert.AreEqual("3", day2.Solve("U"));
        }
Example #7
0
        public void MovingRightOnRightSide_StaysAtNumber()
        {
            Day2 day2 = new Day2();

            Assert.AreEqual("5", day2.Solve(""));
            Assert.AreEqual("6", day2.Solve("R"));
            Assert.AreEqual("6", day2.Solve("R"));
            Assert.AreEqual("3", day2.Solve("U"));
            Assert.AreEqual("3", day2.Solve("R"));
            Assert.AreEqual("6", day2.Solve("D"));
            Assert.AreEqual("9", day2.Solve("D"));
            Assert.AreEqual("9", day2.Solve("R"));
        }
Example #8
0
        public void MovingLeftOnLeftSide_StaysAtNumber()
        {
            Day2 day2 = new Day2();

            Assert.AreEqual("5", day2.Solve(""));
            Assert.AreEqual("4", day2.Solve("L"));
            Assert.AreEqual("4", day2.Solve("L"));
            Assert.AreEqual("1", day2.Solve("U"));
            Assert.AreEqual("1", day2.Solve("L"));
            Assert.AreEqual("4", day2.Solve("D"));
            Assert.AreEqual("7", day2.Solve("D"));
            Assert.AreEqual("7", day2.Solve("L"));
        }
Example #9
0
        public void CanCallSolve()
        {
            Day2 day2 = new Day2();

            Assert.AreEqual("5", day2.Solve(string.Empty));
        }
Example #10
0
        public void Example1()
        {
            Day2 day2 = new Day2();

            Assert.AreEqual("1985", day2.Solve("ULL\nRRDDD\nLURDL\nUUUUD"));
        }
Example #11
0
        static void Main(string[] args)
        {
            Console.WriteLine("Welcome to Advent of Code 2016!");

            bool running = true;

            //TODO: generic ways of doing input
            while (running)
            {
                Console.WriteLine("Please select your day to play or type (exit) to stop");

                string input;
                bool   inputValid = false;

                bool canConvertInput;
                int  day;

                while (!inputValid)
                {
                    input = Console.ReadLine();

                    if (!string.IsNullOrEmpty(input))
                    {
                        canConvertInput = int.TryParse(input, out day);

                        if (canConvertInput)
                        {
                            IDay thisDay = null;

                            switch (day)
                            {
                            case 1:
                                inputValid = true;
                                thisDay    = new Day1();
                                break;

                            case 2:
                                inputValid = true;
                                thisDay    = new Day2();
                                break;

                            case 3:
                                inputValid = true;
                                thisDay    = new Day3();
                                break;

                            case 4:
                                inputValid = true;
                                thisDay    = new Day4();
                                break;

                            case 5:
                                inputValid = true;
                                thisDay    = new Day5();
                                break;

                            case 6:
                                inputValid = true;
                                thisDay    = new Day6();
                                break;

                            case 7:
                                inputValid = true;
                                thisDay    = new Day7();
                                break;

                            case 8:
                                inputValid = true;
                                thisDay    = new Day8();
                                break;

                            case 9:
                                inputValid = true;
                                thisDay    = new Day9();
                                break;

                            case 10:
                                inputValid = true;
                                thisDay    = new Day10();
                                break;

                            case 11:
                            case 12:
                            case 13:
                            case 14:
                            case 15:
                            case 16:
                            case 17:
                            case 18:
                            case 19:
                            case 20:
                            case 21:
                            case 22:
                            case 23:
                            case 24:
                            case 25:
                            default:
                                inputValid = false;
                                Console.WriteLine("I don't know that day, try again");
                                break;
                            }

                            if (thisDay != null)
                            {
                                bool   isAdvancedInputCorrect = false;
                                string advancedInput          = null;

                                while (!isAdvancedInputCorrect)
                                {
                                    Console.WriteLine("The simple (S) or the advanced (A) version?");

                                    advancedInput = Console.ReadLine();

                                    if (advancedInput.ToLower().Equals("simple") || advancedInput.ToUpper().Equals("S"))
                                    {
                                        isAdvancedInputCorrect = true;
                                        thisDay.RunSimple();
                                    }
                                    else if (advancedInput.ToLower().Equals("advanced") || advancedInput.ToUpper().Equals("A"))
                                    {
                                        isAdvancedInputCorrect = true;
                                        thisDay.RunAdvanced();
                                    }
                                    else
                                    {
                                        isAdvancedInputCorrect = false;
                                        Console.WriteLine("That's not what I asked!");
                                    }
                                }
                            }
                        }
                        else
                        {
                            if (input.ToLower().Equals("exit"))
                            {
                                running    = false;
                                inputValid = true;
                            }
                            else
                            {
                                Console.WriteLine("Please input the day number or (exit)");
                            }
                        }
                    }
                }
            }
            Console.WriteLine("Press enter to shut down");
            Console.ReadLine();
        }