コード例 #1
0
ファイル: Program.cs プロジェクト: Blake00789/Advent2020
        static void Main(string[] args)
        {
            var input = GetInputString("day2.txt");

            Console.WriteLine(Day2.Part2(input));
            Console.ReadLine();
        }
コード例 #2
0
        static void Main(string[] args)
        {
            // Day objects:
            Day1 dayOneObject = new Day1();
            Day2 dayTwoObject = new Day2("/Users/jasoncobb/Projects/AdventOfCode2020/AdventOfCode2020/Inputs/Day2.txt");

            Console.WriteLine("Which day would you like to run(1-2)?");
            var inputChoice = Console.ReadLine();

            switch (inputChoice)
            {
            case "1":
                int[] dayOne = dayOneObject.DayOne();
                Console.WriteLine($"Output for Day One Part One is {dayOne[0]}");
                Console.WriteLine($"Output for Day One Part Two is {dayOne[1]}");
                break;

            case "2":
                var dayTwoPartOneResponse = dayTwoObject.dayTwoPartOne();
                var dayTwoPartTwoResponse = dayTwoObject.dayTwoPartTwo();
                Console.WriteLine($"Output for Day Two Part One is {dayTwoPartOneResponse}");
                Console.WriteLine($"Output for Day Two Part Two is {dayTwoPartTwoResponse}");
                break;

            default:
                Console.WriteLine("You either entered an invalid number or a day that hasn't happened yet.");
                break;
            }
        }
コード例 #3
0
        static void Main(string[] args)
        {
            var day1 = new Day1();
            var day2 = new Day2();
            var day3 = new Day3();
            var day4 = new Day4();
            var day5 = new Day5();
            var day6 = new Day6();
            var day7 = new Day7();
            var day8 = new Day8();

            ExecuteAndShowTime(day1.Part1, 1, 1);
            ExecuteAndShowTime(day1.Part2, 1, 2);
            ExecuteAndShowTime(day2.Part1, 2, 1);
            ExecuteAndShowTime(day2.Part2, 2, 2);
            ExecuteAndShowTime(day3.Part1, 3, 1);
            ExecuteAndShowTime(day3.Part2, 3, 2);
            ExecuteAndShowTime(day4.Part1, 4, 1);
            ExecuteAndShowTime(day4.Part2, 4, 2);
            ExecuteAndShowTime(day5.Part1, 5, 1);
            ExecuteAndShowTime(day5.Part2, 5, 2);
            ExecuteAndShowTime(day6.Part1, 6, 1);
            ExecuteAndShowTime(day6.Part2, 6, 2);
            ExecuteAndShowTime(day7.Part1, 7, 1);
            ExecuteAndShowTime(day7.Part2, 7, 2);
            ExecuteAndShowTime(day8.Part1, 8, 1);
        }
コード例 #4
0
 static void Main(string[] args)
 {
     Day1.Execute();
     Day2.Execute();
     Day3.Execute();
     Day4.Execute();
     Console.ReadLine();
 }
コード例 #5
0
        static void Main(string[] args)
        {
            Console.WriteLine("Hello World!");

            Console.WriteLine(Day2.Part2());

            Console.ReadLine();
        }
コード例 #6
0
        private static void SolveDay2()
        {
            StringData data = new StringData(".\\Data\\Day2a.txt");
            Day2       day  = new Day2(data);

            Console.WriteLine("Day2");
            day.SolveToConsole();
            Console.WriteLine("Press any key to continue");
            Console.ReadKey();
        }
コード例 #7
0
ファイル: Program.cs プロジェクト: FowlerAW/AdventOfCode2020
 static void bigDemo()
 {
     Day1.Demo();
     Day2.demo();
     Day3.demo();
     Day4.demo();
     Day5.demo();
     Day6.demo();
     Day7.demo();
     Day8.demo();
     Day9.demo();
 }
コード例 #8
0
ファイル: Program.cs プロジェクト: rayhogan/AdventOfCode2020
        static void Main(string[] args)
        {
            Helper.PrintChallenge("Day 1");
            Day1.Run();

            Helper.PrintChallenge("Day 2");
            Day2.Run();

            Helper.PrintChallenge("Day 3");
            Day3.Run();

            Helper.PrintChallenge("Day 4");
            Day4.Run();

            Helper.PrintChallenge("Day 5");
            Day5.Run();

            Helper.PrintChallenge("Day 6");
            Day6.Run();

            Helper.PrintChallenge("Day 7");
            Day7.Run();

            Helper.PrintChallenge("Day 8");
            Day8.Run();

            Helper.PrintChallenge("Day 9");
            Day9.Run();

            Helper.PrintChallenge("Day 10");
            Day10.Run();

            Helper.PrintChallenge("Day 11");
            Day11.Run();

            Helper.PrintChallenge("Day 12");
            Day12.Run();

            Helper.PrintChallenge("Day 13");
            Day13.Run();

            Helper.PrintChallenge("Day 14");
            Day14.Run();

            Helper.PrintChallenge("Day 15");
            Day15.Run();

            Helper.PrintChallenge("Day 16");
            Day16.Run();

            Helper.PrintChallenge("Day 17");
            Day17.Run();
        }
コード例 #9
0
        public void InitializePuzzle(string path, string cookie, int day)
        {
            Uri uri = new Uri(path);

            using var client = new HttpClient();
            client.DefaultRequestHeaders.Add("Cookie", cookie);
            var response = client.GetStringAsync(uri).Result;

            response.Replace(" ", "");
            string[] values = response.Split("\n");

            if (day == 1)
            {
                Day1.PuzzleA(values);
                Day1.PuzzleB(values);
            }
            if (day == 2)
            {
                Day2.PuzzleA(values);
                Day2.PuzzleB(values);
            }
            if (day == 3)
            {
                Day3.PuzzleA(values);
                Day3.PuzzleB(values);
            }
            if (day == 4)
            {
                Day4.PuzzleA(response);
                Day4.PuzzleB(response);
            }
            if (day == 5)
            {
                Day5.PuzzleA(values);
                Day5.PuzzleB(values);
            }
            if (day == 6)
            {
                Day6.PuzzleA(response);
                Day6.PuzzleB(response);
            }
            if (day == 7)
            {
                Day7.PuzzleA(values);
                Day7.PuzzleB(values);
            }
            if (day == 8)
            {
                Day8.PuzzleA(values);
                Day8.PuzzleB(response);
            }
        }
コード例 #10
0
        static void Main(string[] args)
        {
            Console.WriteLine(Day1.GetPartOneAnswer());
            Console.WriteLine(Day1.GetPartTwoAnswer());

            Console.WriteLine(Day2.GetPartOneAnswer());
            Console.WriteLine(Day2.GetPartTwoAnswer());

            Console.WriteLine(Day3.GetPartOneAnswer());
            Console.WriteLine(Day3.GetPartTwoAnswer());

            Console.ReadLine();
        }
コード例 #11
0
ファイル: Program.cs プロジェクト: danfusion/adventofcode
        static void Main(string[] args)
        {
            Console.Title           = "Advent of Code";
            Console.ForegroundColor = ConsoleColor.Green;

            bool allDone = false;

            while (!allDone)
            {
                PrintMenu();

                int choice;
                while (!int.TryParse(Console.ReadLine(), out choice) || choice < 0 || choice > 25)
                {
                    Console.WriteLine("Invalid input.");
                }

                switch (choice)
                {
                case 0:
                    Console.WriteLine("Exiting...");
                    allDone = true;
                    break;

                case 1:
                    Day1.runDay();

                    Console.Clear();
                    break;

                case 2:
                    Day2.runDay();

                    Console.Clear();
                    break;

                case 3:
                    Day3.runDay();

                    Console.Clear();
                    break;

                default:
                    Console.WriteLine("Exiting...");
                    allDone = true;
                    break;
                }
            }
        }
コード例 #12
0
        public static void Main(string[] args)
        {
            string input;
            IEnumerable <string> rawData;

            do
            {
                Console.Write("Enter a day to display solutions for (or Enter to quit): ");
                input = Console.ReadLine();

                switch (input)
                {
                case "1":
                    rawData = GetData("Day1.txt");
                    int[] numbers = rawData.Select(x => int.Parse(x)).ToArray();
                    Console.WriteLine("Begin Part 1...");
                    Day1.ExecutePart1(numbers);
                    Console.WriteLine("Begin Part 2...");
                    Day1.ExecutePart2(numbers);
                    break;

                case "2":
                    rawData = GetData("Day2.txt");
                    Console.WriteLine("Begin Part 1...");
                    Day2.ExecutePart1(rawData);
                    Console.WriteLine("Begin Part 2...");
                    Day2.ExecutePart2(rawData);
                    break;

                case "3":
                    rawData = GetData("Day3.txt");
                    Console.WriteLine("Begin Part 1...");
                    Day3.ExecutePart1(rawData);
                    Console.WriteLine("Begin Part 2...");
                    Day3.ExecutePart2(rawData);
                    break;

                case "":
                    Console.WriteLine("Goodbye.");
                    break;

                default:
                    Console.WriteLine("Invalid entry.");
                    break;
                }
            } while (input != "");
        }
コード例 #13
0
        static void Main(string[] args)
        {
Start:
            Day4.Part2();
            return;

            Console.WriteLine("Select day (1-25) and Part(1-2) (day.part) : ");
            string input = Console.ReadLine();

            try
            {
                switch (input)
                {
                case "1.1": Day1.Part1(); break;

                case "1.2": Day1.Part2(); break;

                case "2.1": Day2.Part1(); break;

                case "2.2": Day2.Part2(); break;

                case "3.1": Day3.Part1(); break;

                case "3.2": Day3.Part2(); break;

                case "4.1": Day4.Part1(); break;

                case "4.2": Day1.Part1(); break;
                }
            }
            catch (Exception ex)
            {
                Console.Write(ex.Message);
            }
            goto Start;
        }
コード例 #14
0
        static void Main(string[] args)
        {
            //Christmas colors, of course
            Console.BackgroundColor = ConsoleColor.DarkGreen;
            Console.ForegroundColor = ConsoleColor.DarkRed;

            Console.WriteLine("Alex Herreid's solutions to the 2020 Advent of Code");
            Console.WriteLine("***********************");
            Console.WriteLine("Challenges received from https://adventofcode.com/2020/about");
            Console.WriteLine("***********************");
            Console.WriteLine("Challenge copyright original creator, solution copyright Alex Herreid");
            Console.WriteLine("***********************");
            Console.WriteLine("Based on the website description, the goal of the program is to practice coding and collect stars."
                              + " As they write: \"To save your vacation, you need to get all fifty stars by December 25th.\""
                              + " There are two puzzles per day, worth one star each. The full challenge text is not copied here, instead " +
                              "there is just a brief summary on the top of each day of what the code is supposed to do.");

            bool quit = false;

            while (!quit)
            {
                Console.WriteLine("***********************");
                Console.WriteLine();
                Console.WriteLine("Main Menu: (Q to quit)");
                Console.WriteLine("Type in the day number to go to that challenge/solution combo.");
                Console.Write("Day Number: ");
                string input = Console.ReadLine()?.ToUpper();
                if (input == "Q")
                {
                    quit = true;
                }
                else
                {
                    bool validDay = true;
                    if (int.TryParse(input, out int dayNum))
                    {
                        DayPuzzleType?dpt = null;
                        switch (dayNum)
                        {
                        case 1:
                            dpt = DayPuzzleSelector(dayNum);
                            switch (dpt)
                            {
                            case DayPuzzleType.Puzzle1:
                                Day1.Day1_Puzzle1();
                                break;

                            case DayPuzzleType.Puzzle2:
                                Day1.Day1_Puzzle2();
                                break;
                            }
                            break;

                        case 2:
                            dpt = DayPuzzleSelector(dayNum);
                            switch (dpt)
                            {
                            case DayPuzzleType.Puzzle1:
                                Day2.Day2_Puzzle1();
                                break;

                            case DayPuzzleType.Puzzle2:
                                Day2.Day2_Puzzle2();
                                break;
                            }
                            break;

                        case 3:
                            dpt = DayPuzzleSelector(dayNum);
                            switch (dpt)
                            {
                            case DayPuzzleType.Puzzle1:
                                Day3.Day3_Puzzle1();
                                break;

                            case DayPuzzleType.Puzzle2:
                                Day3.Day3_Puzzle2();
                                break;
                            }
                            break;

                        case 4:
                            dpt = DayPuzzleSelector(dayNum);
                            switch (dpt)
                            {
                            case DayPuzzleType.Puzzle1:
                                Day4.Day4_Puzzle1();
                                break;

                            case DayPuzzleType.Puzzle2:
                                Day4.Day4_Puzzle2();
                                break;
                            }
                            break;

                        case 5:
                            dpt = DayPuzzleSelector(dayNum);
                            switch (dpt)
                            {
                            case DayPuzzleType.Puzzle1:
                                Day5.Day5_Puzzle1();
                                break;

                            case DayPuzzleType.Puzzle2:
                                Day5.Day5_Puzzle2();
                                break;
                            }
                            break;

                        case 6:
                            dpt = DayPuzzleSelector(dayNum);
                            switch (dpt)
                            {
                            case DayPuzzleType.Puzzle1:
                                Day6.Day6_Puzzle1();
                                break;

                            case DayPuzzleType.Puzzle2:
                                Day6.Day6_Puzzle2();
                                break;
                            }
                            break;

                        default:
                            validDay = false;
                            break;
                        }
                    }
                    else
                    {
                        validDay = false;
                    }

                    if (!validDay)
                    {
                        Console.Clear();
                        Console.WriteLine("Invalid selection, please try again");
                        Console.WriteLine();
                    }
                }
            }
        }
コード例 #15
0
 static string RunDay2()
 {
     //return Day2.Run(Day2.input).ToString();
     return(Day2.RunPart2(GetInput(2)).ToString());
 }
コード例 #16
0
        static void Main(string[] args)
        {
            Console.WriteLine("Day1");
            Day1.Problem1();
            Day1.Problem2();

            Console.WriteLine("Day2");
            Day2.Problem1();
            Day2.Problem2();

            Console.WriteLine("Day3");
            Day3.Problem1();
            Day3.Problem2();

            Console.WriteLine("Day4");
            Day4.Problem1();
            Day4.Problem2();

            Console.WriteLine("Day5");
            Day5.Problem1();
            Day5.Problem2();

            Console.WriteLine("Day6");
            Day6.Problem1();
            Day6.Problem2();

            Console.WriteLine("Day 7");
            Day7.Problem1();
            Day7.Problem2();

            Console.WriteLine("Day 8");
            Day8.Problem1();
            Day8.Problem2();

            Console.WriteLine("Day 9");
            Day9.Problem1();
            Day9.Problem2();

            Console.WriteLine("Day 10");
            Day10.Problem1();
            Day10.Problem2();

            Console.WriteLine("Day 11");
            Day11.Problem1();
            Day11.Problem2();

            Console.WriteLine("Day 12");
            Day12.Problem1();
            Day12.Problem2();

            Console.WriteLine("Day 13");
            Day13.Problem1();
            Day13.Problem2();

            Console.WriteLine("Day 14");
            Day14.Problem1();
            Day14.Problem2();

            Console.WriteLine("Day 15");
            Day15.Problem1();
            //Day15.Problem2();

            Console.WriteLine("Day 16");
            Day16.Problem1();
            Day16.Problem2();
        }
コード例 #17
0
        //IT WORKS AND I'M TOO LAZY TO ALTER WHAT LOOKED FINE WHEN IT WAS JUST 3 DAYS LONG
        private void Button1_Click(object sender, EventArgs e)
        {
            switch ((int)dayNumber.Value)
            {
            case 1:
                outputBox.Text = "\n- - - - DAY 1 - PART 1 - - - -\n\n" + Day1.PartOneOutput(inputBox.Text);
                break;

            case 2:
                outputBox.Text = "\n- - - - DAY 2 - PART 1 - - - -\n\n" + Day2.PartOneOutput(inputBox.Text);
                break;

            case 3:
                outputBox.Text = "\n- - - - DAY 3 - PART 1 - - - -\n\n" + Day3.PartOneOutput(inputBox.Text);
                break;

            case 4:
                outputBox.Text = "\n- - - - DAY 4 - PART 1 - - - -\n\n" + Day4.PartOneOutput(inputBox.Text);
                break;

            case 5:
                outputBox.Text = "\n- - - - DAY 5 - PART 1 - - - -\n\n" + Day5.PartOneOutput(inputBox.Text);
                break;

            case 6:
                outputBox.Text = "\n- - - - DAY 6 - PART 1 - - - -\n\n" + Day6.PartOneOutput(inputBox.Text);
                break;

            case 7:
                outputBox.Text = "\n- - - - DAY 7 - PART 1 - - - -\n\n" + Day7.PartOneOutput(inputBox.Text);
                break;

            case 8:
                outputBox.Text = "\n- - - - DAY 8 - PART 1 - - - -\n\n" + Day8.PartOneOutput(inputBox.Text);
                break;

            case 9:
                outputBox.Text = "\n- - - - DAY 9 - PART 1 - - - -\n\n" + Day9.PartOneOutput(inputBox.Text);
                break;

            case 10:
                outputBox.Text = "\n- - - - DAY 10 - PART 1 - - - -\n\n" + Day10.PartOneOutput(inputBox.Text);
                break;

            case 11:
                outputBox.Text = "\n- - - - DAY 11 - PART 1 - - - -\n\n" + Day11.PartOneOutput(inputBox.Text);
                break;

            case 12:
                outputBox.Text = "\n- - - - DAY 12 - PART 1 - - - -\n\n" + Day12.PartOneOutput(inputBox.Text);
                break;

            case 13:
                outputBox.Text = "\n- - - - DAY 13 - PART 1 - - - -\n\n" + Day13.PartOneOutput(inputBox.Text);
                break;

            case 14:
                outputBox.Text = "\n- - - - DAY 14 - PART 1 - - - -\n\n" + Day14.PartOneOutput(inputBox.Text);
                break;

            case 15:
                outputBox.Text = "\n- - - - DAY 15 - PART 1 - - - -\n\n" + Day15.PartOneOutput(inputBox.Text);
                break;

            case 16:
                outputBox.Text = "\n- - - - DAY 16 - PART 1 - - - -\n\n" + Day16.PartOneOutput(inputBox.Text);
                break;

            case 17:
                outputBox.Text = "\n- - - - DAY 17 - PART 1 - - - -\n\n" + Day17.PartOneOutput(inputBox.Text);
                break;

            case 18:
                outputBox.Text = "\n- - - - DAY 18 - PART 1 - - - -\n\n" + Day18.PartOneOutput(inputBox.Text);
                break;

            case 19:
                outputBox.Text = "\n- - - - DAY 19 - PART 1 - - - -\n\n" + Day19.PartOneOutput(inputBox.Text);
                break;

            case 20:
                outputBox.Text = "\n- - - - DAY 20 - PART 1 - - - -\n\n" + Day20.PartOneOutput(inputBox.Text);
                break;

            case 21:
                outputBox.Text = "\n- - - - DAY 21 - PART 1 - - - -\n\n" + Day21.PartOneOutput(inputBox.Text);
                break;

            case 22:
                outputBox.Text = "\n- - - - DAY 22 - PART 1 - - - -\n\n" + Day22.PartOneOutput(inputBox.Text);
                break;

            case 23:
                outputBox.Text = "\n- - - - DAY 23 - PART 1 - - - -\n\n" + Day23.PartOneOutput(inputBox.Text);
                break;

            case 24:
                outputBox.Text = "\n- - - - DAY 24 - PART 1 - - - -\n\n" + Day24.PartOneOutput(inputBox.Text);
                break;

            case 25:
                outputBox.Text = "\n- - - - DAY 25 - PART 1 - - - -\n\n" + Day25.PartOneOutput(inputBox.Text);
                break;

            default:
                break;
            }
        }