From 3846b42b7ec8907917fbad3758d7b26d4ad2f533 Mon Sep 17 00:00:00 2001 From: Rob Date: Sun, 3 Dec 2023 19:09:26 +0100 Subject: [PATCH] Massive code base change partial completion of day 3 --- Advend Of Code Runner/Program.cs | 19 - .../AdventOfCode.Runner.csproj | 4 +- AdvendOfCode.Runner/Program.cs | 13 + Advent Of Code.sln | 30 +- .../AdventOfCode.Core.csproj | 4 + .../InputReader.cs | 32 +- .../Shared/A-Star/AStarGrid.cs | 0 .../Shared/A-Star/AStarNode.cs | 0 .../Shared/Answerable.cs | 2 +- .../Shared/AnswerableListBuilder.cs | 0 .../Shared/Grid.cs | 12 +- AdventOfCode.Core/Shared/IChallange.cs | 9 + .../Shared/Node.cs | 15 +- .../2022/Day 01/Day01Part1.cs | 0 .../2022/Day 01/Day01Part2.cs | 0 .../2022/Day 01/day-01-input.txt | 0 .../2022/Day 02/Day02Part1.cs | 0 .../2022/Day 02/Day02Part2.cs | 0 .../2022/Day 02/GameRules.cs | 0 .../2022/Day 02/day-02-input.txt | 0 .../2022/Day 03/Day03Part1.cs | 0 .../2022/Day 03/Day03Part2.cs | 0 .../2022/Day 03/day-03-input.txt | 0 .../2022/Day 04/Day04Part1.cs | 0 .../2022/Day 04/Day04Part2.cs | 0 .../2022/Day 04/day-04-input.txt | 0 .../2022/Day 05/CraneWork.cs | 0 .../2022/Day 05/Day05Part1.cs | 0 .../2022/Day 05/Day05Part2.cs | 0 .../2022/Day 05/day-05-input.txt | 0 .../2022/Day 06/Day06Part1.cs | 0 .../2022/Day 06/Day06Part2.cs | 0 .../2022/Day 06/day-06-input.txt | 0 .../2022/Day 07/Day07Part1.cs | 0 .../2022/Day 07/Day07Part2.cs | 0 .../2022/Day 07/DirectoryManager.cs | 0 .../2022/Day 07/day-07-input.txt | 0 .../2022/Day 08/Day08Part1.cs | 0 .../2022/Day 08/Day08Part2.cs | 0 .../2022/Day 08/day-08-input.txt | 196 +- .../2022/Day 09/Day09Part1.cs | 0 .../2022/Day 09/Day09Part2.cs | 0 .../2022/Day 09/RopeWalker.cs | 150 +- .../2022/Day 09/day-09-input.txt | 3998 ++++++++--------- .../2022/Day 10/Day10Part1.cs | 0 .../2022/Day 10/Day10Part2.cs | 0 .../2022/Day 10/day-10-input.txt | 272 +- .../2022/Day 11/Day11Part1.cs | 0 .../2022/Day 11/Day11Part2.cs | 0 .../2022/Day 11/Monkey.cs | 276 +- .../2022/Day 11/day-11-input.txt | 0 .../2022/Day 12/Day12Part1.cs | 0 .../2022/Day 12/Day12Part2.cs | 0 .../2022/Day 12/Map.cs | 0 .../2022/Day 12/day-12-input.txt | 108 +- .../2023/Day 01/Day01Part1.cs | 0 .../2023/Day 01/Day01Part2.cs | 0 .../2023/Day 01/day-01-input.txt | 0 .../2023/Day 02/Day02Part1.cs | 0 .../2023/Day 02/Day02Part2.cs | 0 .../2023/Day 02/day-02-input.txt | 0 AdventOfCode.Solutions/2023/Day 03/Day03.cs | 123 + .../2023/Day 03/day-03-input.txt | 140 + .../AdventOfCode.Solutions.csproj | 8 +- .../Usings.cs | 0 AdventOfCode.Solutions/day-00-input.txt | 10 + 66 files changed, 2872 insertions(+), 2549 deletions(-) delete mode 100644 Advend Of Code Runner/Program.cs rename {Advend Of Code Runner => AdvendOfCode.Runner}/AdventOfCode.Runner.csproj (71%) create mode 100644 AdvendOfCode.Runner/Program.cs rename {AdventOfCode.Code => AdventOfCode.Core}/AdventOfCode.Core.csproj (72%) rename {AdventOfCode.Code => AdventOfCode.Core}/InputReader.cs (59%) rename {AdventOfCode.Code => AdventOfCode.Core}/Shared/A-Star/AStarGrid.cs (100%) rename {AdventOfCode.Code => AdventOfCode.Core}/Shared/A-Star/AStarNode.cs (100%) rename {AdventOfCode.Code => AdventOfCode.Core}/Shared/Answerable.cs (95%) rename {AdventOfCode.Code => AdventOfCode.Core}/Shared/AnswerableListBuilder.cs (100%) rename {AdventOfCode.Code => AdventOfCode.Core}/Shared/Grid.cs (71%) create mode 100644 AdventOfCode.Core/Shared/IChallange.cs rename {AdventOfCode.Code => AdventOfCode.Core}/Shared/Node.cs (60%) rename {Advent Of Code Library => AdventOfCode.Solutions}/2022/Day 01/Day01Part1.cs (100%) rename {Advent Of Code Library => AdventOfCode.Solutions}/2022/Day 01/Day01Part2.cs (100%) rename {Advent Of Code Library => AdventOfCode.Solutions}/2022/Day 01/day-01-input.txt (100%) rename {Advent Of Code Library => AdventOfCode.Solutions}/2022/Day 02/Day02Part1.cs (100%) rename {Advent Of Code Library => AdventOfCode.Solutions}/2022/Day 02/Day02Part2.cs (100%) rename {Advent Of Code Library => AdventOfCode.Solutions}/2022/Day 02/GameRules.cs (100%) rename {Advent Of Code Library => AdventOfCode.Solutions}/2022/Day 02/day-02-input.txt (100%) rename {Advent Of Code Library => AdventOfCode.Solutions}/2022/Day 03/Day03Part1.cs (100%) rename {Advent Of Code Library => AdventOfCode.Solutions}/2022/Day 03/Day03Part2.cs (100%) rename {Advent Of Code Library => AdventOfCode.Solutions}/2022/Day 03/day-03-input.txt (100%) rename {Advent Of Code Library => AdventOfCode.Solutions}/2022/Day 04/Day04Part1.cs (100%) rename {Advent Of Code Library => AdventOfCode.Solutions}/2022/Day 04/Day04Part2.cs (100%) rename {Advent Of Code Library => AdventOfCode.Solutions}/2022/Day 04/day-04-input.txt (100%) rename {Advent Of Code Library => AdventOfCode.Solutions}/2022/Day 05/CraneWork.cs (100%) rename {Advent Of Code Library => AdventOfCode.Solutions}/2022/Day 05/Day05Part1.cs (100%) rename {Advent Of Code Library => AdventOfCode.Solutions}/2022/Day 05/Day05Part2.cs (100%) rename {Advent Of Code Library => AdventOfCode.Solutions}/2022/Day 05/day-05-input.txt (100%) rename {Advent Of Code Library => AdventOfCode.Solutions}/2022/Day 06/Day06Part1.cs (100%) rename {Advent Of Code Library => AdventOfCode.Solutions}/2022/Day 06/Day06Part2.cs (100%) rename {Advent Of Code Library => AdventOfCode.Solutions}/2022/Day 06/day-06-input.txt (100%) rename {Advent Of Code Library => AdventOfCode.Solutions}/2022/Day 07/Day07Part1.cs (100%) rename {Advent Of Code Library => AdventOfCode.Solutions}/2022/Day 07/Day07Part2.cs (100%) rename {Advent Of Code Library => AdventOfCode.Solutions}/2022/Day 07/DirectoryManager.cs (100%) rename {Advent Of Code Library => AdventOfCode.Solutions}/2022/Day 07/day-07-input.txt (100%) rename {Advent Of Code Library => AdventOfCode.Solutions}/2022/Day 08/Day08Part1.cs (100%) rename {Advent Of Code Library => AdventOfCode.Solutions}/2022/Day 08/Day08Part2.cs (100%) rename {Advent Of Code Library => AdventOfCode.Solutions}/2022/Day 08/day-08-input.txt (99%) rename {Advent Of Code Library => AdventOfCode.Solutions}/2022/Day 09/Day09Part1.cs (100%) rename {Advent Of Code Library => AdventOfCode.Solutions}/2022/Day 09/Day09Part2.cs (100%) rename {Advent Of Code Library => AdventOfCode.Solutions}/2022/Day 09/RopeWalker.cs (97%) rename {Advent Of Code Library => AdventOfCode.Solutions}/2022/Day 09/day-09-input.txt (80%) rename {Advent Of Code Library => AdventOfCode.Solutions}/2022/Day 10/Day10Part1.cs (100%) rename {Advent Of Code Library => AdventOfCode.Solutions}/2022/Day 10/Day10Part2.cs (100%) rename {Advent Of Code Library => AdventOfCode.Solutions}/2022/Day 10/day-10-input.txt (87%) rename {Advent Of Code Library => AdventOfCode.Solutions}/2022/Day 11/Day11Part1.cs (100%) rename {Advent Of Code Library => AdventOfCode.Solutions}/2022/Day 11/Day11Part2.cs (100%) rename {Advent Of Code Library => AdventOfCode.Solutions}/2022/Day 11/Monkey.cs (96%) rename Advent Of Code Library/2022/Day 12/day-12-input.txt => AdventOfCode.Solutions/2022/Day 11/day-11-input.txt (100%) rename {Advent Of Code Library => AdventOfCode.Solutions}/2022/Day 12/Day12Part1.cs (100%) rename {Advent Of Code Library => AdventOfCode.Solutions}/2022/Day 12/Day12Part2.cs (100%) rename {Advent Of Code Library => AdventOfCode.Solutions}/2022/Day 12/Map.cs (100%) rename Advent Of Code Library/2022/Day 11/day-11-input.txt => AdventOfCode.Solutions/2022/Day 12/day-12-input.txt (95%) rename {Advent Of Code Library => AdventOfCode.Solutions}/2023/Day 01/Day01Part1.cs (100%) rename {Advent Of Code Library => AdventOfCode.Solutions}/2023/Day 01/Day01Part2.cs (100%) rename {Advent Of Code Library => AdventOfCode.Solutions}/2023/Day 01/day-01-input.txt (100%) rename {Advent Of Code Library => AdventOfCode.Solutions}/2023/Day 02/Day02Part1.cs (100%) rename {Advent Of Code Library => AdventOfCode.Solutions}/2023/Day 02/Day02Part2.cs (100%) rename {Advent Of Code Library => AdventOfCode.Solutions}/2023/Day 02/day-02-input.txt (100%) create mode 100644 AdventOfCode.Solutions/2023/Day 03/Day03.cs create mode 100644 AdventOfCode.Solutions/2023/Day 03/day-03-input.txt rename {Advent Of Code Library => AdventOfCode.Solutions}/AdventOfCode.Solutions.csproj (59%) rename {Advent Of Code Library => AdventOfCode.Solutions}/Usings.cs (100%) create mode 100644 AdventOfCode.Solutions/day-00-input.txt diff --git a/Advend Of Code Runner/Program.cs b/Advend Of Code Runner/Program.cs deleted file mode 100644 index b55dc20..0000000 --- a/Advend Of Code Runner/Program.cs +++ /dev/null @@ -1,19 +0,0 @@ -using System.Text; - -using AdventOfCodeLibrary._2023; -using AdventOfCode.Core.Shared; - -string _demoData = @"Game 1: 3 blue, 4 red; 1 red, 2 green, 6 blue; 2 green -Game 2: 1 blue, 2 green; 3 green, 4 blue, 1 red; 1 green, 1 blue -Game 3: 8 green, 6 blue, 20 red; 5 blue, 4 red, 13 green; 5 green, 1 red -Game 4: 1 green, 3 red, 6 blue; 3 green, 6 red; 3 green, 15 blue, 14 red -Game 5: 6 red, 1 blue, 3 green; 2 blue, 1 red, 2 green"; - -Answerable answerable = new Day02Part2(); - -//FileStream stream = new FileStream(answerable.DefaultInputFile, new FileStreamOptions { Mode = FileMode.Open, Access = FileAccess.Read, Options = FileOptions.Asynchronous }); - -byte[] dataArray = File.ReadAllBytes(answerable.DefaultInputFile); -//dataArray = Encoding.UTF8.GetBytes(_demoData); - -Console.WriteLine($"Answer: {answerable.GetAnswer(dataArray)}"); diff --git a/Advend Of Code Runner/AdventOfCode.Runner.csproj b/AdvendOfCode.Runner/AdventOfCode.Runner.csproj similarity index 71% rename from Advend Of Code Runner/AdventOfCode.Runner.csproj rename to AdvendOfCode.Runner/AdventOfCode.Runner.csproj index 70f62d0..39f8435 100644 --- a/Advend Of Code Runner/AdventOfCode.Runner.csproj +++ b/AdvendOfCode.Runner/AdventOfCode.Runner.csproj @@ -3,13 +3,13 @@ Exe net8.0 - AdventOFCodeRunner + AdventOfCode.Runner enable enable - + diff --git a/AdvendOfCode.Runner/Program.cs b/AdvendOfCode.Runner/Program.cs new file mode 100644 index 0000000..ad21c94 --- /dev/null +++ b/AdvendOfCode.Runner/Program.cs @@ -0,0 +1,13 @@ +using AdventOfCode.Solutions._2023; +using AdventOfCode.Core.Shared; +using AdventOfCode.Core; + +InputReader inputReader = new() +{ + IsDebug = true +}; +IChallange challange = new Day03(inputReader); + +Console.WriteLine($"Part 1: {await challange.GetSolutionPart1()}"); + +Console.WriteLine($"Part 2: {await challange.GetSolutionPart2()}"); \ No newline at end of file diff --git a/Advent Of Code.sln b/Advent Of Code.sln index 279fe15..f9de55a 100644 --- a/Advent Of Code.sln +++ b/Advent Of Code.sln @@ -3,11 +3,11 @@ Microsoft Visual Studio Solution File, Format Version 12.00 # Visual Studio Version 17 VisualStudioVersion = 17.4.33103.184 MinimumVisualStudioVersion = 10.0.40219.1 -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "AdventOfCode.Runner", "Advend Of Code Runner\AdventOfCode.Runner.csproj", "{6DCDC513-AF72-4029-932A-A0079BB5422B}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "AdventOfCode.Core", "AdventOfCode.Core\AdventOfCode.Core.csproj", "{61EF900D-0CDB-4FC2-8E13-73BEFE0A36E0}" EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "AdventOfCode.Solutions", "Advent Of Code Library\AdventOfCode.Solutions.csproj", "{33CC3924-F18E-4B88-9989-A7A9077B9AC4}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "AdventOfCode.Solutions", "AdventOfCode.Solutions\AdventOfCode.Solutions.csproj", "{BDDFE214-9F20-4BF7-94C6-19BAAF130FDA}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "AdventOfCode.Core", "AdventOfCode.Code\AdventOfCode.Core.csproj", "{49EFF2F1-A5AD-448F-92EE-8CC95B2CECC2}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "AdventOfCode.Runner", "AdvendOfCode.Runner\AdventOfCode.Runner.csproj", "{9A188168-565C-4D82-8C81-DD3A15386863}" EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution @@ -15,18 +15,18 @@ Global Release|Any CPU = Release|Any CPU EndGlobalSection GlobalSection(ProjectConfigurationPlatforms) = postSolution - {6DCDC513-AF72-4029-932A-A0079BB5422B}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {6DCDC513-AF72-4029-932A-A0079BB5422B}.Debug|Any CPU.Build.0 = Debug|Any CPU - {6DCDC513-AF72-4029-932A-A0079BB5422B}.Release|Any CPU.ActiveCfg = Release|Any CPU - {6DCDC513-AF72-4029-932A-A0079BB5422B}.Release|Any CPU.Build.0 = Release|Any CPU - {33CC3924-F18E-4B88-9989-A7A9077B9AC4}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {33CC3924-F18E-4B88-9989-A7A9077B9AC4}.Debug|Any CPU.Build.0 = Debug|Any CPU - {33CC3924-F18E-4B88-9989-A7A9077B9AC4}.Release|Any CPU.ActiveCfg = Release|Any CPU - {33CC3924-F18E-4B88-9989-A7A9077B9AC4}.Release|Any CPU.Build.0 = Release|Any CPU - {49EFF2F1-A5AD-448F-92EE-8CC95B2CECC2}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {49EFF2F1-A5AD-448F-92EE-8CC95B2CECC2}.Debug|Any CPU.Build.0 = Debug|Any CPU - {49EFF2F1-A5AD-448F-92EE-8CC95B2CECC2}.Release|Any CPU.ActiveCfg = Release|Any CPU - {49EFF2F1-A5AD-448F-92EE-8CC95B2CECC2}.Release|Any CPU.Build.0 = Release|Any CPU + {61EF900D-0CDB-4FC2-8E13-73BEFE0A36E0}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {61EF900D-0CDB-4FC2-8E13-73BEFE0A36E0}.Debug|Any CPU.Build.0 = Debug|Any CPU + {61EF900D-0CDB-4FC2-8E13-73BEFE0A36E0}.Release|Any CPU.ActiveCfg = Release|Any CPU + {61EF900D-0CDB-4FC2-8E13-73BEFE0A36E0}.Release|Any CPU.Build.0 = Release|Any CPU + {BDDFE214-9F20-4BF7-94C6-19BAAF130FDA}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {BDDFE214-9F20-4BF7-94C6-19BAAF130FDA}.Debug|Any CPU.Build.0 = Debug|Any CPU + {BDDFE214-9F20-4BF7-94C6-19BAAF130FDA}.Release|Any CPU.ActiveCfg = Release|Any CPU + {BDDFE214-9F20-4BF7-94C6-19BAAF130FDA}.Release|Any CPU.Build.0 = Release|Any CPU + {9A188168-565C-4D82-8C81-DD3A15386863}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {9A188168-565C-4D82-8C81-DD3A15386863}.Debug|Any CPU.Build.0 = Debug|Any CPU + {9A188168-565C-4D82-8C81-DD3A15386863}.Release|Any CPU.ActiveCfg = Release|Any CPU + {9A188168-565C-4D82-8C81-DD3A15386863}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE diff --git a/AdventOfCode.Code/AdventOfCode.Core.csproj b/AdventOfCode.Core/AdventOfCode.Core.csproj similarity index 72% rename from AdventOfCode.Code/AdventOfCode.Core.csproj rename to AdventOfCode.Core/AdventOfCode.Core.csproj index fa71b7a..3197b13 100644 --- a/AdventOfCode.Code/AdventOfCode.Core.csproj +++ b/AdventOfCode.Core/AdventOfCode.Core.csproj @@ -6,4 +6,8 @@ enable + + + + diff --git a/AdventOfCode.Code/InputReader.cs b/AdventOfCode.Core/InputReader.cs similarity index 59% rename from AdventOfCode.Code/InputReader.cs rename to AdventOfCode.Core/InputReader.cs index cda462e..3ec7095 100644 --- a/AdventOfCode.Code/InputReader.cs +++ b/AdventOfCode.Core/InputReader.cs @@ -1,13 +1,19 @@ -using System.Runtime.InteropServices.Marshalling; +using AdventOfCode.Core.Shared; namespace AdventOfCode.Core { public class InputReader { - private readonly string InputFileTemplate = "../../../../Advent Of Code Library/{1}/Day {2:00}/day-{2:00}-input.txt"; + private readonly string InputFileTemplate = "../../../../AdventOfCode.Solutions/{1}/Day {0:00}/day-{0:00}-input.txt"; + private readonly string DebugInputFileTemplate = "../../../../AdventOfCode.Solutions/day-00-input.txt"; + public bool IsDebug = false; + + private int Day { get; set; } private int Year { get; set; } - private string InputFilePath => string.Format(InputFileTemplate, Year, Day); + private string InputFilePath => IsDebug ? DebugInputFileTemplate : string.Format(InputFileTemplate, Day, Year); + + public InputReader() => SetInputByChallange(); public void SetInputByChallange() { @@ -36,6 +42,11 @@ namespace AdventOfCode.Core } } + public Task ReadAsArraytString() + { + return File.ReadAllLinesAsync(InputFilePath); + } + public async IAsyncEnumerable ReadAsStringLine(T emptyLineIndicator) { using StreamReader reader = new(InputFilePath); @@ -48,5 +59,20 @@ namespace AdventOfCode.Core yield return (T)Convert.ChangeType(line, typeof(T)); } } + + public async Task> ReadToGrid() where T : Node, new() + { + Grid result = new(); + int row = 0; + await foreach(string line in ReadAsStringLine()) + { + int charIndex = 0; + // create the nodes from the lines + result.DataGrid.AddRange(line.Select(c => new T { X = charIndex++, Y = row, Char = c })); + row++; + } + + return result; + } } } diff --git a/AdventOfCode.Code/Shared/A-Star/AStarGrid.cs b/AdventOfCode.Core/Shared/A-Star/AStarGrid.cs similarity index 100% rename from AdventOfCode.Code/Shared/A-Star/AStarGrid.cs rename to AdventOfCode.Core/Shared/A-Star/AStarGrid.cs diff --git a/AdventOfCode.Code/Shared/A-Star/AStarNode.cs b/AdventOfCode.Core/Shared/A-Star/AStarNode.cs similarity index 100% rename from AdventOfCode.Code/Shared/A-Star/AStarNode.cs rename to AdventOfCode.Core/Shared/A-Star/AStarNode.cs diff --git a/AdventOfCode.Code/Shared/Answerable.cs b/AdventOfCode.Core/Shared/Answerable.cs similarity index 95% rename from AdventOfCode.Code/Shared/Answerable.cs rename to AdventOfCode.Core/Shared/Answerable.cs index 543b08b..797c474 100644 --- a/AdventOfCode.Code/Shared/Answerable.cs +++ b/AdventOfCode.Core/Shared/Answerable.cs @@ -1,8 +1,8 @@ using System.Text; +using System.Text.RegularExpressions; namespace AdventOfCode.Core.Shared { - using System.Text.RegularExpressions; public abstract class Answerable { diff --git a/AdventOfCode.Code/Shared/AnswerableListBuilder.cs b/AdventOfCode.Core/Shared/AnswerableListBuilder.cs similarity index 100% rename from AdventOfCode.Code/Shared/AnswerableListBuilder.cs rename to AdventOfCode.Core/Shared/AnswerableListBuilder.cs diff --git a/AdventOfCode.Code/Shared/Grid.cs b/AdventOfCode.Core/Shared/Grid.cs similarity index 71% rename from AdventOfCode.Code/Shared/Grid.cs rename to AdventOfCode.Core/Shared/Grid.cs index b34443c..c2aba66 100644 --- a/AdventOfCode.Code/Shared/Grid.cs +++ b/AdventOfCode.Core/Shared/Grid.cs @@ -1,10 +1,10 @@ -using System.Collections.Generic; - -namespace AdventOfCode.Core.Shared +namespace AdventOfCode.Core.Shared { public class Grid where T : Node { - public List DataGrid { get; set; } = new List(); + public List DataGrid { get; set; } = []; + + public Grid() { } public Grid(T[] data) => DataGrid.AddRange(data); @@ -23,7 +23,11 @@ namespace AdventOfCode.Core.Shared } return neighbors.Where(target => !(Math.Abs(source.X - target.X) <= 1 && Math.Abs(source.Y - target.Y) <= 1)); + } + public IEnumerable GetSection(int fromX, int fromY, int toX, int toY) + { + return DataGrid.Where(node => node.X >= fromX && node.X <= toX && node.Y >= fromY && node.Y <= toY); } } diff --git a/AdventOfCode.Core/Shared/IChallange.cs b/AdventOfCode.Core/Shared/IChallange.cs new file mode 100644 index 0000000..ce6ac3f --- /dev/null +++ b/AdventOfCode.Core/Shared/IChallange.cs @@ -0,0 +1,9 @@ +namespace AdventOfCode.Core.Shared +{ + public interface IChallange + { + Task GetSolutionPart1(); + + Task GetSolutionPart2(); + } +} diff --git a/AdventOfCode.Code/Shared/Node.cs b/AdventOfCode.Core/Shared/Node.cs similarity index 60% rename from AdventOfCode.Code/Shared/Node.cs rename to AdventOfCode.Core/Shared/Node.cs index 423a917..ca07908 100644 --- a/AdventOfCode.Code/Shared/Node.cs +++ b/AdventOfCode.Core/Shared/Node.cs @@ -2,10 +2,12 @@ { public class Node { - internal int X { get; set; } - internal int Y { get; set; } - internal char Char { get; } - internal short Integer => (short)Char; + public int X { get; set; } + public int Y { get; set; } + public char Char { get; set; } + public short Integer => (short)Char; + + public Node() { } public Node(int x, int y, char character) { @@ -21,5 +23,10 @@ { return Math.Abs(X - other.X) + Math.Abs(Y - other.Y); } + + public override string ToString() + { + return $"[{Y},{X}] {Char}"; + } } } diff --git a/Advent Of Code Library/2022/Day 01/Day01Part1.cs b/AdventOfCode.Solutions/2022/Day 01/Day01Part1.cs similarity index 100% rename from Advent Of Code Library/2022/Day 01/Day01Part1.cs rename to AdventOfCode.Solutions/2022/Day 01/Day01Part1.cs diff --git a/Advent Of Code Library/2022/Day 01/Day01Part2.cs b/AdventOfCode.Solutions/2022/Day 01/Day01Part2.cs similarity index 100% rename from Advent Of Code Library/2022/Day 01/Day01Part2.cs rename to AdventOfCode.Solutions/2022/Day 01/Day01Part2.cs diff --git a/Advent Of Code Library/2022/Day 01/day-01-input.txt b/AdventOfCode.Solutions/2022/Day 01/day-01-input.txt similarity index 100% rename from Advent Of Code Library/2022/Day 01/day-01-input.txt rename to AdventOfCode.Solutions/2022/Day 01/day-01-input.txt diff --git a/Advent Of Code Library/2022/Day 02/Day02Part1.cs b/AdventOfCode.Solutions/2022/Day 02/Day02Part1.cs similarity index 100% rename from Advent Of Code Library/2022/Day 02/Day02Part1.cs rename to AdventOfCode.Solutions/2022/Day 02/Day02Part1.cs diff --git a/Advent Of Code Library/2022/Day 02/Day02Part2.cs b/AdventOfCode.Solutions/2022/Day 02/Day02Part2.cs similarity index 100% rename from Advent Of Code Library/2022/Day 02/Day02Part2.cs rename to AdventOfCode.Solutions/2022/Day 02/Day02Part2.cs diff --git a/Advent Of Code Library/2022/Day 02/GameRules.cs b/AdventOfCode.Solutions/2022/Day 02/GameRules.cs similarity index 100% rename from Advent Of Code Library/2022/Day 02/GameRules.cs rename to AdventOfCode.Solutions/2022/Day 02/GameRules.cs diff --git a/Advent Of Code Library/2022/Day 02/day-02-input.txt b/AdventOfCode.Solutions/2022/Day 02/day-02-input.txt similarity index 100% rename from Advent Of Code Library/2022/Day 02/day-02-input.txt rename to AdventOfCode.Solutions/2022/Day 02/day-02-input.txt diff --git a/Advent Of Code Library/2022/Day 03/Day03Part1.cs b/AdventOfCode.Solutions/2022/Day 03/Day03Part1.cs similarity index 100% rename from Advent Of Code Library/2022/Day 03/Day03Part1.cs rename to AdventOfCode.Solutions/2022/Day 03/Day03Part1.cs diff --git a/Advent Of Code Library/2022/Day 03/Day03Part2.cs b/AdventOfCode.Solutions/2022/Day 03/Day03Part2.cs similarity index 100% rename from Advent Of Code Library/2022/Day 03/Day03Part2.cs rename to AdventOfCode.Solutions/2022/Day 03/Day03Part2.cs diff --git a/Advent Of Code Library/2022/Day 03/day-03-input.txt b/AdventOfCode.Solutions/2022/Day 03/day-03-input.txt similarity index 100% rename from Advent Of Code Library/2022/Day 03/day-03-input.txt rename to AdventOfCode.Solutions/2022/Day 03/day-03-input.txt diff --git a/Advent Of Code Library/2022/Day 04/Day04Part1.cs b/AdventOfCode.Solutions/2022/Day 04/Day04Part1.cs similarity index 100% rename from Advent Of Code Library/2022/Day 04/Day04Part1.cs rename to AdventOfCode.Solutions/2022/Day 04/Day04Part1.cs diff --git a/Advent Of Code Library/2022/Day 04/Day04Part2.cs b/AdventOfCode.Solutions/2022/Day 04/Day04Part2.cs similarity index 100% rename from Advent Of Code Library/2022/Day 04/Day04Part2.cs rename to AdventOfCode.Solutions/2022/Day 04/Day04Part2.cs diff --git a/Advent Of Code Library/2022/Day 04/day-04-input.txt b/AdventOfCode.Solutions/2022/Day 04/day-04-input.txt similarity index 100% rename from Advent Of Code Library/2022/Day 04/day-04-input.txt rename to AdventOfCode.Solutions/2022/Day 04/day-04-input.txt diff --git a/Advent Of Code Library/2022/Day 05/CraneWork.cs b/AdventOfCode.Solutions/2022/Day 05/CraneWork.cs similarity index 100% rename from Advent Of Code Library/2022/Day 05/CraneWork.cs rename to AdventOfCode.Solutions/2022/Day 05/CraneWork.cs diff --git a/Advent Of Code Library/2022/Day 05/Day05Part1.cs b/AdventOfCode.Solutions/2022/Day 05/Day05Part1.cs similarity index 100% rename from Advent Of Code Library/2022/Day 05/Day05Part1.cs rename to AdventOfCode.Solutions/2022/Day 05/Day05Part1.cs diff --git a/Advent Of Code Library/2022/Day 05/Day05Part2.cs b/AdventOfCode.Solutions/2022/Day 05/Day05Part2.cs similarity index 100% rename from Advent Of Code Library/2022/Day 05/Day05Part2.cs rename to AdventOfCode.Solutions/2022/Day 05/Day05Part2.cs diff --git a/Advent Of Code Library/2022/Day 05/day-05-input.txt b/AdventOfCode.Solutions/2022/Day 05/day-05-input.txt similarity index 100% rename from Advent Of Code Library/2022/Day 05/day-05-input.txt rename to AdventOfCode.Solutions/2022/Day 05/day-05-input.txt diff --git a/Advent Of Code Library/2022/Day 06/Day06Part1.cs b/AdventOfCode.Solutions/2022/Day 06/Day06Part1.cs similarity index 100% rename from Advent Of Code Library/2022/Day 06/Day06Part1.cs rename to AdventOfCode.Solutions/2022/Day 06/Day06Part1.cs diff --git a/Advent Of Code Library/2022/Day 06/Day06Part2.cs b/AdventOfCode.Solutions/2022/Day 06/Day06Part2.cs similarity index 100% rename from Advent Of Code Library/2022/Day 06/Day06Part2.cs rename to AdventOfCode.Solutions/2022/Day 06/Day06Part2.cs diff --git a/Advent Of Code Library/2022/Day 06/day-06-input.txt b/AdventOfCode.Solutions/2022/Day 06/day-06-input.txt similarity index 100% rename from Advent Of Code Library/2022/Day 06/day-06-input.txt rename to AdventOfCode.Solutions/2022/Day 06/day-06-input.txt diff --git a/Advent Of Code Library/2022/Day 07/Day07Part1.cs b/AdventOfCode.Solutions/2022/Day 07/Day07Part1.cs similarity index 100% rename from Advent Of Code Library/2022/Day 07/Day07Part1.cs rename to AdventOfCode.Solutions/2022/Day 07/Day07Part1.cs diff --git a/Advent Of Code Library/2022/Day 07/Day07Part2.cs b/AdventOfCode.Solutions/2022/Day 07/Day07Part2.cs similarity index 100% rename from Advent Of Code Library/2022/Day 07/Day07Part2.cs rename to AdventOfCode.Solutions/2022/Day 07/Day07Part2.cs diff --git a/Advent Of Code Library/2022/Day 07/DirectoryManager.cs b/AdventOfCode.Solutions/2022/Day 07/DirectoryManager.cs similarity index 100% rename from Advent Of Code Library/2022/Day 07/DirectoryManager.cs rename to AdventOfCode.Solutions/2022/Day 07/DirectoryManager.cs diff --git a/Advent Of Code Library/2022/Day 07/day-07-input.txt b/AdventOfCode.Solutions/2022/Day 07/day-07-input.txt similarity index 100% rename from Advent Of Code Library/2022/Day 07/day-07-input.txt rename to AdventOfCode.Solutions/2022/Day 07/day-07-input.txt diff --git a/Advent Of Code Library/2022/Day 08/Day08Part1.cs b/AdventOfCode.Solutions/2022/Day 08/Day08Part1.cs similarity index 100% rename from Advent Of Code Library/2022/Day 08/Day08Part1.cs rename to AdventOfCode.Solutions/2022/Day 08/Day08Part1.cs diff --git a/Advent Of Code Library/2022/Day 08/Day08Part2.cs b/AdventOfCode.Solutions/2022/Day 08/Day08Part2.cs similarity index 100% rename from Advent Of Code Library/2022/Day 08/Day08Part2.cs rename to AdventOfCode.Solutions/2022/Day 08/Day08Part2.cs diff --git a/Advent Of Code Library/2022/Day 08/day-08-input.txt b/AdventOfCode.Solutions/2022/Day 08/day-08-input.txt similarity index 99% rename from Advent Of Code Library/2022/Day 08/day-08-input.txt rename to AdventOfCode.Solutions/2022/Day 08/day-08-input.txt index c850492..d27a06c 100644 --- a/Advent Of Code Library/2022/Day 08/day-08-input.txt +++ b/AdventOfCode.Solutions/2022/Day 08/day-08-input.txt @@ -1,99 +1,99 @@ -202210010310302121322210423201220000314024242432211425434422230130411300321324302223011311211020120 -110110101310322320101034033124303343031143435122351113353455142421341123420341013300312303121102011 -022222013123323313404200430243020022232555432244334344444542122134130133413044342230233130022021112 -112111200212221204100121022244121453412414141145154551512445525421435232112124343223122023223002202 -010223032133232313122112411243113131542422453412413325334141424132125341004123403342031113000321021 -120203310013001113014232132353322341235134523424131353554135433255424414441323410043113010210021012 -001321033020303133033413032514323122112454135451341114535233523552111335315303411442413103332313030 -102233001100013210130402551555541521113335452154222626521451545151431543531541120332311401123233002 -000012220223113031313123321342142243351454565666666364326432622135251241345515402410441240003203231 -323120110213212212143353534544223242346225556633526325233365442515315454452135521422031032430131220 -010220310331203330225142431325531126553665336562254653354425352265653122233143242323103214302312331 -123101224243131422134414233423334544425633524646243233362664535663664554135351555324200233211032302 -100333303112401243331523125333225424454222662442543663456556432565564235231542334341022204140131010 -222320010441120114425514454524226565533325532623432265362636256446244663333511523325400304340133002 -001134131023140453514341254322262544543344626564433544326342336243252564355555514153411041322321023 -303032023104304131222142562326266256323662554334643363347342242532462534263352425422433133134401332 -020340310211345254242454444265454332565537636676554374476536357464242334364525332231411442341304333 -010424244214451151434435346345243633344375647763655474336663454733535632266334124355143530400222002 -020104234232554141451622326322264263647735447654367457344444465643453634336365231214525124433022444 -204201130004331123325262634265424363534754356365344543544653337444375665555552553542414222233041401 -231313304412112545143543446626577766674444573674633355336777737535543536546633462414421512204234400 -033341420245341341444352655236656744666536473763766674637573737455777566262423256254341313453322144 -440314332142235331442343546273646373345664657448647878767773563537357677642454354424141113554434301 -002021425352244536243253565466455346736677674884448677865868476765656674742534363462451133433430431 -312244242113113354564554337535376574767786648687855878644777578636677645574425532235315311343242411 -233122245155144565255556333557536764847587685667467874688477765747736733566463344232665353434242041 -022220452513455555322662755373537664785775876754758887458644778857853773647663236626545124422424320 -022230332331242525645255575733445554454765688768654845485674575556756764377537266433342513111411334 -120341111522144552663266354477644845848748677677644558776677456646677433474757754324325455254224404 -334433112533124466362636446457755674575647767878689757997654655557447467734646643623663324241123341 -044044511253635465446534354447476746444884889989857597797866787787888747443665545532456524224131143 -342122313235634465626773753655655586857767998568657675697899684787888655564663564432663444345124541 -300241415543242222674376454758578748859965896985789659878795778758468578856474655622353223553421340 -432555555434536525465544664745745888686778996656856565599757587746755745784533654644233622425515434 -004155142463225235434575577777764766596665569657879795765857577596467458644447634453564363532531433 -315114345132332442746733438647847847577597775567596889586878967997655654786546753744554456313434213 -323554311133626266375345655745865485788569878887677897756998589576556656784677663746632663332532151 -315144132232553537533354554654464598875898876799867967877875556975854576455736577735632354543155134 -222334432553634533666733477687556985579999867776999997898668878678867858466445453753652435255552353 -341334452524465435553736485655557568559699788977996667669999667955587886767744364375524653661522332 -413445246252544336676458575775678988988586687776978669888789889868875866467477435474464653535223233 -113143446226365337646448856475467575668778966797986666789967987866989544578754333667436355422314512 -323412424644366374665378846687555957879987766978769867869789986867696554454854656763756625325241145 -323421115545525643633547858847889999697776668979678976769897999899659875558684777565446323544324251 -432334334444542573375354656474858797778897676698987797799688968867795956877875445655545264424345232 -313421526625464654745784667555655877667866889997977998979899968958766968688884745767745342336522224 -122211264264562763544488484689975989588788879988798787779667786859558567878485674347334443246223344 -255242155636622443335485578658568685878777677999787778898767686987558788876846566435373364366424533 -413344156256433653574768654788878777978699969878998798887869869888598888664446534547775236363642425 -342124563455467737457658485456878998989988979899998897787987866875698669856575853463673655444534341 -232551266232426674334688468579688769898979978897788788899798868699975575444474737764445664236253252 -525112465464323755636656578776889996878689879787788998889987978986957695855668736377766252323353255 -335335445554653644563344554685858987978878788987977879778999967667869567488847763473767565562443553 -545321524224436644545685678886975585679878668999989988977889988665666777667584866437364423354233323 -111423266342443746543667554476875575666977668887778798797767868895568959486564657554473632445655344 -524212552355364477347365556488688656986668766897897789886896688988559599878748555366373562653454121 -131154335433422345634645655457568556886876787789779979987866669967997578577754745577462646226445314 -235252452335234564367678476887687995897898668678778786687699867598786667847747567563645652263343425 -223253143456366656767765746865557567566666767869789987989986887557956998685474637637366352326243542 -022325555334456567353758847454499775865697766886666678799897866988858868887447554444762544422112415 -343144416534333377537365468647569967688667888678877876698688967696987958488474576533553236464222515 -041455413553636645474356566857777797955967797767896696888698558569799657885773667663642263333432225 -314232125326436446553663846575645898685777676969798987998978856859686786577445377553744443245432243 -321243223546455364367743474758777659578658777997668897788989566685788888684476563345423344554443231 -415125254422442527666573645787574596577688978657789966586986685976985678486637347667436525212454543 -414235135545633363666356438757467669858969857687755898578857676858688644547753747345432366312551541 -440114242344345546336647565757454586855999757667866776678779875958488554786743465373523322335324440 -122344413244444335537455544748467554578788577997879979696958696984755857587433556336643245424414511 -404152532353256326373573456764878788486665786786686989885788858787846674744354647343463555324212243 -430052142415544522224767753334887658877858987557899587585858774486467688656755647656562452215444341 -340214451142655354335334667467484748684647966577756797796876564684745486774456744624442332555544214 -202003423413136555225554443743364668647485745965556658974868564455687766677646333424563244225312413 -124244252232546632354435547477575454458474888785648855588868547656747434644644562666356425513552234 -110004343225254552232245333753757468577454458667486664868686776847774656744433232645435354515511001 -114110243523312246646633667657446557887764577875444674586445668855646455464673426355246121241420242 -144004022115232335325233544457463354556577558686866645777668486456344336776563552654224535341204000 -421204313533552465364335665657756377478687485747568464457586578433533665377544334436324115345110242 -310213102455533546266535624345334376363684858775467657685555747353643644472546632522545411333203111 -114430325255224412546642432664757677554453367648667474866563366653547673545643556525445241221014044 -101202024124311141332246625344457736763773743567676364434654335437667673333633334533321141144401343 -022314412343141552545426345523734644465534437755555546366776455573555736346566554523431445312041141 -310102320115113413255662622463666645774475764474763576347553464576657544655232265213412332113321240 -103421443124221314341526656425352447567466347367455546655457665443752365626234642233144534440401232 -012242102421432341212413443326266462435353334443757554636776575352564544364326345342233211400021132 -222333320014022434154332424323323222343565375555437333746365455224462465255645335454253531041200430 -203301220423445445245343333566523444245653734664355375366356543225425453566551115535422214404241002 -302324443031122331441331256335344224253636533556756445434643354532564454235413132113211343002133211 -311312211414143323513134241534622563433242365626656422526345223354546364435315451551101023211412130 -222110343401032043553425111312244654332653464666435423342453322663424243153233322113032023202020223 -323230200411432130355525221321433355242633433225442453325522522622364253311533334354031100222010013 -310222312143433114242431355515315554643534324342445656666436353223444231435453241400213321330130010 -333003032313304033243534455111112214234262552344526635435332246231323535122413441024143242102302110 -113023202303413323324054115321135342223354425566256536556255312115424353351151533010221413210330113 -201002101132013010411214525353534241113423251253436544643553152152432455455322331331310031222312310 -010000023323114442204233214145222453523254543111213112525444545451354241122320331344023330301010000 -020221201301204043241340212025231451554512545355544454355334235544331435121232034423404333303220120 -211200133121002321411044312343241534545415435535214551522523534521342510432012433211020132222223110 -001010111333021232114033432123014243143421131445211232544521554534542030434313341020033312233321020 +202210010310302121322210423201220000314024242432211425434422230130411300321324302223011311211020120 +110110101310322320101034033124303343031143435122351113353455142421341123420341013300312303121102011 +022222013123323313404200430243020022232555432244334344444542122134130133413044342230233130022021112 +112111200212221204100121022244121453412414141145154551512445525421435232112124343223122023223002202 +010223032133232313122112411243113131542422453412413325334141424132125341004123403342031113000321021 +120203310013001113014232132353322341235134523424131353554135433255424414441323410043113010210021012 +001321033020303133033413032514323122112454135451341114535233523552111335315303411442413103332313030 +102233001100013210130402551555541521113335452154222626521451545151431543531541120332311401123233002 +000012220223113031313123321342142243351454565666666364326432622135251241345515402410441240003203231 +323120110213212212143353534544223242346225556633526325233365442515315454452135521422031032430131220 +010220310331203330225142431325531126553665336562254653354425352265653122233143242323103214302312331 +123101224243131422134414233423334544425633524646243233362664535663664554135351555324200233211032302 +100333303112401243331523125333225424454222662442543663456556432565564235231542334341022204140131010 +222320010441120114425514454524226565533325532623432265362636256446244663333511523325400304340133002 +001134131023140453514341254322262544543344626564433544326342336243252564355555514153411041322321023 +303032023104304131222142562326266256323662554334643363347342242532462534263352425422433133134401332 +020340310211345254242454444265454332565537636676554374476536357464242334364525332231411442341304333 +010424244214451151434435346345243633344375647763655474336663454733535632266334124355143530400222002 +020104234232554141451622326322264263647735447654367457344444465643453634336365231214525124433022444 +204201130004331123325262634265424363534754356365344543544653337444375665555552553542414222233041401 +231313304412112545143543446626577766674444573674633355336777737535543536546633462414421512204234400 +033341420245341341444352655236656744666536473763766674637573737455777566262423256254341313453322144 +440314332142235331442343546273646373345664657448647878767773563537357677642454354424141113554434301 +002021425352244536243253565466455346736677674884448677865868476765656674742534363462451133433430431 +312244242113113354564554337535376574767786648687855878644777578636677645574425532235315311343242411 +233122245155144565255556333557536764847587685667467874688477765747736733566463344232665353434242041 +022220452513455555322662755373537664785775876754758887458644778857853773647663236626545124422424320 +022230332331242525645255575733445554454765688768654845485674575556756764377537266433342513111411334 +120341111522144552663266354477644845848748677677644558776677456646677433474757754324325455254224404 +334433112533124466362636446457755674575647767878689757997654655557447467734646643623663324241123341 +044044511253635465446534354447476746444884889989857597797866787787888747443665545532456524224131143 +342122313235634465626773753655655586857767998568657675697899684787888655564663564432663444345124541 +300241415543242222674376454758578748859965896985789659878795778758468578856474655622353223553421340 +432555555434536525465544664745745888686778996656856565599757587746755745784533654644233622425515434 +004155142463225235434575577777764766596665569657879795765857577596467458644447634453564363532531433 +315114345132332442746733438647847847577597775567596889586878967997655654786546753744554456313434213 +323554311133626266375345655745865485788569878887677897756998589576556656784677663746632663332532151 +315144132232553537533354554654464598875898876799867967877875556975854576455736577735632354543155134 +222334432553634533666733477687556985579999867776999997898668878678867858466445453753652435255552353 +341334452524465435553736485655557568559699788977996667669999667955587886767744364375524653661522332 +413445246252544336676458575775678988988586687776978669888789889868875866467477435474464653535223233 +113143446226365337646448856475467575668778966797986666789967987866989544578754333667436355422314512 +323412424644366374665378846687555957879987766978769867869789986867696554454854656763756625325241145 +323421115545525643633547858847889999697776668979678976769897999899659875558684777565446323544324251 +432334334444542573375354656474858797778897676698987797799688968867795956877875445655545264424345232 +313421526625464654745784667555655877667866889997977998979899968958766968688884745767745342336522224 +122211264264562763544488484689975989588788879988798787779667786859558567878485674347334443246223344 +255242155636622443335485578658568685878777677999787778898767686987558788876846566435373364366424533 +413344156256433653574768654788878777978699969878998798887869869888598888664446534547775236363642425 +342124563455467737457658485456878998989988979899998897787987866875698669856575853463673655444534341 +232551266232426674334688468579688769898979978897788788899798868699975575444474737764445664236253252 +525112465464323755636656578776889996878689879787788998889987978986957695855668736377766252323353255 +335335445554653644563344554685858987978878788987977879778999967667869567488847763473767565562443553 +545321524224436644545685678886975585679878668999989988977889988665666777667584866437364423354233323 +111423266342443746543667554476875575666977668887778798797767868895568959486564657554473632445655344 +524212552355364477347365556488688656986668766897897789886896688988559599878748555366373562653454121 +131154335433422345634645655457568556886876787789779979987866669967997578577754745577462646226445314 +235252452335234564367678476887687995897898668678778786687699867598786667847747567563645652263343425 +223253143456366656767765746865557567566666767869789987989986887557956998685474637637366352326243542 +022325555334456567353758847454499775865697766886666678799897866988858868887447554444762544422112415 +343144416534333377537365468647569967688667888678877876698688967696987958488474576533553236464222515 +041455413553636645474356566857777797955967797767896696888698558569799657885773667663642263333432225 +314232125326436446553663846575645898685777676969798987998978856859686786577445377553744443245432243 +321243223546455364367743474758777659578658777997668897788989566685788888684476563345423344554443231 +415125254422442527666573645787574596577688978657789966586986685976985678486637347667436525212454543 +414235135545633363666356438757467669858969857687755898578857676858688644547753747345432366312551541 +440114242344345546336647565757454586855999757667866776678779875958488554786743465373523322335324440 +122344413244444335537455544748467554578788577997879979696958696984755857587433556336643245424414511 +404152532353256326373573456764878788486665786786686989885788858787846674744354647343463555324212243 +430052142415544522224767753334887658877858987557899587585858774486467688656755647656562452215444341 +340214451142655354335334667467484748684647966577756797796876564684745486774456744624442332555544214 +202003423413136555225554443743364668647485745965556658974868564455687766677646333424563244225312413 +124244252232546632354435547477575454458474888785648855588868547656747434644644562666356425513552234 +110004343225254552232245333753757468577454458667486664868686776847774656744433232645435354515511001 +114110243523312246646633667657446557887764577875444674586445668855646455464673426355246121241420242 +144004022115232335325233544457463354556577558686866645777668486456344336776563552654224535341204000 +421204313533552465364335665657756377478687485747568464457586578433533665377544334436324115345110242 +310213102455533546266535624345334376363684858775467657685555747353643644472546632522545411333203111 +114430325255224412546642432664757677554453367648667474866563366653547673545643556525445241221014044 +101202024124311141332246625344457736763773743567676364434654335437667673333633334533321141144401343 +022314412343141552545426345523734644465534437755555546366776455573555736346566554523431445312041141 +310102320115113413255662622463666645774475764474763576347553464576657544655232265213412332113321240 +103421443124221314341526656425352447567466347367455546655457665443752365626234642233144534440401232 +012242102421432341212413443326266462435353334443757554636776575352564544364326345342233211400021132 +222333320014022434154332424323323222343565375555437333746365455224462465255645335454253531041200430 +203301220423445445245343333566523444245653734664355375366356543225425453566551115535422214404241002 +302324443031122331441331256335344224253636533556756445434643354532564454235413132113211343002133211 +311312211414143323513134241534622563433242365626656422526345223354546364435315451551101023211412130 +222110343401032043553425111312244654332653464666435423342453322663424243153233322113032023202020223 +323230200411432130355525221321433355242633433225442453325522522622364253311533334354031100222010013 +310222312143433114242431355515315554643534324342445656666436353223444231435453241400213321330130010 +333003032313304033243534455111112214234262552344526635435332246231323535122413441024143242102302110 +113023202303413323324054115321135342223354425566256536556255312115424353351151533010221413210330113 +201002101132013010411214525353534241113423251253436544643553152152432455455322331331310031222312310 +010000023323114442204233214145222453523254543111213112525444545451354241122320331344023330301010000 +020221201301204043241340212025231451554512545355544454355334235544331435121232034423404333303220120 +211200133121002321411044312343241534545415435535214551522523534521342510432012433211020132222223110 +001010111333021232114033432123014243143421131445211232544521554534542030434313341020033312233321020 110102200233103010320200140144034422131352541143533213514525422131220112004103004000011012120121220 \ No newline at end of file diff --git a/Advent Of Code Library/2022/Day 09/Day09Part1.cs b/AdventOfCode.Solutions/2022/Day 09/Day09Part1.cs similarity index 100% rename from Advent Of Code Library/2022/Day 09/Day09Part1.cs rename to AdventOfCode.Solutions/2022/Day 09/Day09Part1.cs diff --git a/Advent Of Code Library/2022/Day 09/Day09Part2.cs b/AdventOfCode.Solutions/2022/Day 09/Day09Part2.cs similarity index 100% rename from Advent Of Code Library/2022/Day 09/Day09Part2.cs rename to AdventOfCode.Solutions/2022/Day 09/Day09Part2.cs diff --git a/Advent Of Code Library/2022/Day 09/RopeWalker.cs b/AdventOfCode.Solutions/2022/Day 09/RopeWalker.cs similarity index 97% rename from Advent Of Code Library/2022/Day 09/RopeWalker.cs rename to AdventOfCode.Solutions/2022/Day 09/RopeWalker.cs index 4bb91e9..72952ee 100644 --- a/Advent Of Code Library/2022/Day 09/RopeWalker.cs +++ b/AdventOfCode.Solutions/2022/Day 09/RopeWalker.cs @@ -1,75 +1,75 @@ -namespace AdventOfCode.Solutions._2022.Day_09 -{ - internal class VirtualPoint - { - internal int X { get; set; } = 0; - - internal int Y { get; set; } = 0; - - internal void Translate(int x, int y) - { - X += x; - Y += y; - } - } - - internal class RopeWalker - { - private List TailVistedLocations = new(); - - internal int ProcessMovement(string[] movements, int ropeLength) - { - VirtualPoint[] rope = new VirtualPoint[ropeLength]; - for (int ropeIndex = 0; ropeIndex < rope.Length; ropeIndex++) - { - rope[ropeIndex] = new VirtualPoint(); - } - - // add the start position - TailVistedLocations.Add($"0,0"); - - for (int movementIndex = 0; movementIndex < movements.Length; movementIndex++) - { - char direction = movements[movementIndex][0]; - int amountToMove = Convert.ToInt32(movements[movementIndex].Substring(2)); - - for (int movement = 0; movement < amountToMove; movement++) - { - - // do the actual move - switch (direction) - { - case 'U': rope[0].Translate(0, 1); break; - case 'D': rope[0].Translate(0, -1); break; - case 'R': rope[0].Translate(1, 0); break; - case 'L': rope[0].Translate(-1, 0); break; - } - - for (int ropeIndex = 1; ropeIndex < rope.Length; ropeIndex++) - { - if (!IsTailTouchingHead(rope[ropeIndex - 1], rope[ropeIndex])) - { - rope[ropeIndex].Translate(Math.Sign(rope[ropeIndex - 1].X - rope[ropeIndex].X), Math.Sign(rope[ropeIndex - 1].Y - rope[ropeIndex].Y)); - - // add the new position to the list of visited positions - - continue; - } - - // if not touching nothing has changed so stop with checking - break; - } - - TailVistedLocations.Add($"{rope[^1].X},{rope[^1].Y}"); - } - } - - return TailVistedLocations.Distinct().Count(); - } - - private bool IsTailTouchingHead(VirtualPoint point1, VirtualPoint point2) - { - return !(Math.Abs(point1.X - point2.X) > 1) && !(Math.Abs(point1.Y - point2.Y) > 1); - } - } -} +namespace AdventOfCode.Solutions._2022.Day_09 +{ + internal class VirtualPoint + { + internal int X { get; set; } = 0; + + internal int Y { get; set; } = 0; + + internal void Translate(int x, int y) + { + X += x; + Y += y; + } + } + + internal class RopeWalker + { + private List TailVistedLocations = new(); + + internal int ProcessMovement(string[] movements, int ropeLength) + { + VirtualPoint[] rope = new VirtualPoint[ropeLength]; + for (int ropeIndex = 0; ropeIndex < rope.Length; ropeIndex++) + { + rope[ropeIndex] = new VirtualPoint(); + } + + // add the start position + TailVistedLocations.Add($"0,0"); + + for (int movementIndex = 0; movementIndex < movements.Length; movementIndex++) + { + char direction = movements[movementIndex][0]; + int amountToMove = Convert.ToInt32(movements[movementIndex].Substring(2)); + + for (int movement = 0; movement < amountToMove; movement++) + { + + // do the actual move + switch (direction) + { + case 'U': rope[0].Translate(0, 1); break; + case 'D': rope[0].Translate(0, -1); break; + case 'R': rope[0].Translate(1, 0); break; + case 'L': rope[0].Translate(-1, 0); break; + } + + for (int ropeIndex = 1; ropeIndex < rope.Length; ropeIndex++) + { + if (!IsTailTouchingHead(rope[ropeIndex - 1], rope[ropeIndex])) + { + rope[ropeIndex].Translate(Math.Sign(rope[ropeIndex - 1].X - rope[ropeIndex].X), Math.Sign(rope[ropeIndex - 1].Y - rope[ropeIndex].Y)); + + // add the new position to the list of visited positions + + continue; + } + + // if not touching nothing has changed so stop with checking + break; + } + + TailVistedLocations.Add($"{rope[^1].X},{rope[^1].Y}"); + } + } + + return TailVistedLocations.Distinct().Count(); + } + + private bool IsTailTouchingHead(VirtualPoint point1, VirtualPoint point2) + { + return !(Math.Abs(point1.X - point2.X) > 1) && !(Math.Abs(point1.Y - point2.Y) > 1); + } + } +} diff --git a/Advent Of Code Library/2022/Day 09/day-09-input.txt b/AdventOfCode.Solutions/2022/Day 09/day-09-input.txt similarity index 80% rename from Advent Of Code Library/2022/Day 09/day-09-input.txt rename to AdventOfCode.Solutions/2022/Day 09/day-09-input.txt index 1ecc932..50b479c 100644 --- a/Advent Of Code Library/2022/Day 09/day-09-input.txt +++ b/AdventOfCode.Solutions/2022/Day 09/day-09-input.txt @@ -1,2000 +1,2000 @@ -R 1 -L 1 -U 1 -L 2 -U 2 -D 2 -U 1 -R 1 -D 1 -R 2 -D 1 -U 1 -D 2 -R 2 -L 2 -R 2 -D 2 -R 2 -D 1 -L 2 -U 1 -R 2 -U 1 -L 1 -D 1 -R 1 -L 1 -D 2 -L 2 -U 1 -R 1 -L 2 -U 2 -D 2 -L 2 -R 1 -L 2 -U 2 -L 2 -D 2 -U 2 -D 1 -L 2 -D 1 -L 1 -D 2 -R 1 -D 1 -R 2 -D 2 -U 2 -D 2 -L 1 -R 1 -D 1 -L 1 -U 1 -L 2 -R 1 -U 2 -L 1 -D 2 -L 1 -D 2 -U 1 -L 1 -D 1 -R 2 -L 2 -R 2 -L 2 -D 1 -U 2 -L 1 -U 1 -R 2 -D 1 -R 2 -L 2 -D 1 -R 2 -U 1 -D 1 -L 2 -R 1 -U 1 -D 1 -L 2 -D 1 -L 2 -U 2 -R 1 -L 1 -D 2 -U 1 -D 1 -U 1 -R 2 -L 2 -R 2 -L 2 -U 2 -L 1 -U 1 -L 2 -R 2 -L 1 -U 1 -R 2 -U 1 -L 2 -D 1 -U 2 -D 1 -L 1 -U 3 -D 3 -L 1 -D 1 -L 2 -D 1 -R 2 -U 1 -D 3 -R 1 -U 1 -D 2 -U 3 -D 2 -U 2 -R 3 -D 3 -L 1 -R 2 -U 3 -D 2 -R 3 -U 1 -L 3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R 17 -L 3 -U 7 -D 2 -R 12 -U 9 -R 1 -U 8 -L 5 -U 15 -R 5 -U 15 -L 6 -U 2 -D 10 -L 17 -R 15 -U 3 -R 18 -L 4 -R 13 -D 10 -L 5 -R 14 -L 12 -U 11 -R 3 -U 16 -R 16 -D 6 -R 16 -L 15 -R 9 -U 1 -L 15 -U 14 -L 2 -R 14 -L 16 -D 1 -R 16 -L 1 -U 6 -D 2 -U 6 -R 1 -U 11 -R 1 -L 14 -U 18 -D 8 -L 13 -D 7 -R 13 -U 18 -D 10 -U 7 -D 11 -L 11 -U 7 -D 12 -L 14 -R 1 -L 16 -U 16 -L 10 -D 8 -U 9 -L 1 -R 18 -D 7 -R 6 -L 5 -R 9 -U 12 -R 11 -D 9 -R 5 -L 13 -R 8 -D 2 -R 12 -L 14 -R 6 -L 16 -D 8 -U 18 -L 5 -D 15 -U 7 -R 18 -U 6 -R 5 -L 18 -R 9 -U 15 -R 15 -D 4 -R 7 -D 18 -L 18 -R 15 -D 8 -L 16 -D 17 -U 5 -L 16 -D 11 -R 5 -U 7 -D 2 -R 11 -U 17 -L 3 -R 9 -U 11 -D 6 -L 8 -R 11 -U 17 -D 2 -R 16 -U 2 -L 15 -D 11 -U 7 -R 16 -U 14 -L 4 -R 8 -D 18 -R 9 -U 18 -L 10 -D 16 -U 15 -D 19 -L 16 -D 17 -L 6 -U 16 -D 7 -L 5 -U 2 -D 11 -U 9 -L 4 -U 5 -R 10 -L 17 -D 16 -U 7 -D 16 -U 15 -R 3 -U 16 -R 15 -L 3 -U 14 -R 5 -L 6 -U 5 -D 4 -R 19 -D 3 -U 8 -D 12 -R 19 -U 18 -R 5 -U 5 -L 14 -D 6 -R 9 -L 19 -D 10 -U 18 -L 5 -D 6 -L 12 -U 13 -R 19 -U 4 -R 1 -L 6 -D 14 -L 17 -D 19 -L 2 -R 13 -U 18 -D 14 -U 11 -R 19 -L 8 -R 12 -L 3 -U 19 -R 5 -L 4 -D 9 -U 9 -L 19 -U 16 -L 1 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U 18 +D 8 +L 13 +D 7 +R 13 +U 18 +D 10 +U 7 +D 11 +L 11 +U 7 +D 12 +L 14 +R 1 +L 16 +U 16 +L 10 +D 8 +U 9 +L 1 +R 18 +D 7 +R 6 +L 5 +R 9 +U 12 +R 11 +D 9 +R 5 +L 13 +R 8 +D 2 +R 12 +L 14 +R 6 +L 16 +D 8 +U 18 +L 5 +D 15 +U 7 +R 18 +U 6 +R 5 +L 18 +R 9 +U 15 +R 15 +D 4 +R 7 +D 18 +L 18 +R 15 +D 8 +L 16 +D 17 +U 5 +L 16 +D 11 +R 5 +U 7 +D 2 +R 11 +U 17 +L 3 +R 9 +U 11 +D 6 +L 8 +R 11 +U 17 +D 2 +R 16 +U 2 +L 15 +D 11 +U 7 +R 16 +U 14 +L 4 +R 8 +D 18 +R 9 +U 18 +L 10 +D 16 +U 15 +D 19 +L 16 +D 17 +L 6 +U 16 +D 7 +L 5 +U 2 +D 11 +U 9 +L 4 +U 5 +R 10 +L 17 +D 16 +U 7 +D 16 +U 15 +R 3 +U 16 +R 15 +L 3 +U 14 +R 5 +L 6 +U 5 +D 4 +R 19 +D 3 +U 8 +D 12 +R 19 +U 18 +R 5 +U 5 +L 14 +D 6 +R 9 +L 19 +D 10 +U 18 +L 5 +D 6 +L 12 +U 13 +R 19 +U 4 +R 1 +L 6 +D 14 +L 17 +D 19 +L 2 +R 13 +U 18 +D 14 +U 11 +R 19 +L 8 +R 12 +L 3 +U 19 +R 5 +L 4 +D 9 +U 9 +L 19 +U 16 +L 1 +D 9 +R 15 +L 16 +R 2 +D 1 +L 7 +U 1 +D 4 +L 19 +R 15 +D 7 +U 7 +L 17 +D 9 +U 19 +D 6 +R 19 U 16 \ No newline at end of file diff --git a/Advent Of Code Library/2022/Day 10/Day10Part1.cs b/AdventOfCode.Solutions/2022/Day 10/Day10Part1.cs similarity index 100% rename from Advent Of Code Library/2022/Day 10/Day10Part1.cs rename to AdventOfCode.Solutions/2022/Day 10/Day10Part1.cs diff --git a/Advent Of Code Library/2022/Day 10/Day10Part2.cs b/AdventOfCode.Solutions/2022/Day 10/Day10Part2.cs similarity index 100% rename from Advent Of Code Library/2022/Day 10/Day10Part2.cs rename to AdventOfCode.Solutions/2022/Day 10/Day10Part2.cs diff --git a/Advent Of Code Library/2022/Day 10/day-10-input.txt b/AdventOfCode.Solutions/2022/Day 10/day-10-input.txt similarity index 87% rename from Advent Of Code Library/2022/Day 10/day-10-input.txt rename to AdventOfCode.Solutions/2022/Day 10/day-10-input.txt index 033e54f..8962ee5 100644 --- a/Advent Of Code Library/2022/Day 10/day-10-input.txt +++ b/AdventOfCode.Solutions/2022/Day 10/day-10-input.txt @@ -1,137 +1,137 @@ -addx 1 -noop -addx 2 -addx 5 -addx 3 -noop -addx -1 -addx 5 -noop -noop -addx 5 -noop -addx 3 -noop -addx 6 -addx -4 -noop -noop -addx 5 -noop -addx -32 -addx 35 -addx 5 -addx -31 -addx 7 -addx -13 -addx 2 -addx 2 -addx 5 -addx 6 -addx -5 -addx 2 -addx 5 -addx 2 -addx 2 -addx -17 -addx 18 -addx 5 -addx 2 -addx -30 -addx 31 -addx 2 -addx 2 -addx -32 -addx -1 -addx 10 -addx -8 -noop -noop -addx 6 -addx 16 -noop -addx -11 -addx 3 -addx -2 -addx 3 -noop -addx 6 -noop -addx -2 -noop -addx 7 -addx 3 -addx -2 -addx 4 -addx -20 -noop -addx -14 -addx -2 -addx 6 -addx 2 -addx 3 -noop -addx 2 -addx -1 -addx 4 -noop -addx 5 -noop -addx 2 -addx 3 -addx -2 -addx 3 -noop -addx 4 -noop -addx 5 -noop -addx 2 -addx -24 -addx -15 -addx 17 -addx -10 -addx 2 -addx -5 -addx 6 -noop -addx 3 -addx 2 -addx 2 -noop -addx 3 -addx 2 -addx 5 -addx -2 -addx 3 -addx 2 -addx 2 -addx 5 -addx 2 -addx -18 -addx -19 -noop -addx 1 -addx 2 -addx 5 -addx 3 -noop -noop -noop -noop -addx 2 -addx 5 -addx 2 -addx 3 -noop -addx -8 -addx 11 -noop -noop -addx 2 -addx 5 -addx 2 -addx 3 -noop -addx -34 +addx 1 +noop +addx 2 +addx 5 +addx 3 +noop +addx -1 +addx 5 +noop +noop +addx 5 +noop +addx 3 +noop +addx 6 +addx -4 +noop +noop +addx 5 +noop +addx -32 +addx 35 +addx 5 +addx -31 +addx 7 +addx -13 +addx 2 +addx 2 +addx 5 +addx 6 +addx -5 +addx 2 +addx 5 +addx 2 +addx 2 +addx -17 +addx 18 +addx 5 +addx 2 +addx -30 +addx 31 +addx 2 +addx 2 +addx -32 +addx -1 +addx 10 +addx -8 +noop +noop +addx 6 +addx 16 +noop +addx -11 +addx 3 +addx -2 +addx 3 +noop +addx 6 +noop +addx -2 +noop +addx 7 +addx 3 +addx -2 +addx 4 +addx -20 +noop +addx -14 +addx -2 +addx 6 +addx 2 +addx 3 +noop +addx 2 +addx -1 +addx 4 +noop +addx 5 +noop +addx 2 +addx 3 +addx -2 +addx 3 +noop +addx 4 +noop +addx 5 +noop +addx 2 +addx -24 +addx -15 +addx 17 +addx -10 +addx 2 +addx -5 +addx 6 +noop +addx 3 +addx 2 +addx 2 +noop +addx 3 +addx 2 +addx 5 +addx -2 +addx 3 +addx 2 +addx 2 +addx 5 +addx 2 +addx -18 +addx -19 +noop +addx 1 +addx 2 +addx 5 +addx 3 +noop +noop +noop +noop +addx 2 +addx 5 +addx 2 +addx 3 +noop +addx -8 +addx 11 +noop +noop +addx 2 +addx 5 +addx 2 +addx 3 +noop +addx -34 noop \ No newline at end of file diff --git a/Advent Of Code Library/2022/Day 11/Day11Part1.cs b/AdventOfCode.Solutions/2022/Day 11/Day11Part1.cs similarity index 100% rename from Advent Of Code Library/2022/Day 11/Day11Part1.cs rename to AdventOfCode.Solutions/2022/Day 11/Day11Part1.cs diff --git a/Advent Of Code Library/2022/Day 11/Day11Part2.cs b/AdventOfCode.Solutions/2022/Day 11/Day11Part2.cs similarity index 100% rename from Advent Of Code Library/2022/Day 11/Day11Part2.cs rename to AdventOfCode.Solutions/2022/Day 11/Day11Part2.cs diff --git a/Advent Of Code Library/2022/Day 11/Monkey.cs b/AdventOfCode.Solutions/2022/Day 11/Monkey.cs similarity index 96% rename from Advent Of Code Library/2022/Day 11/Monkey.cs rename to AdventOfCode.Solutions/2022/Day 11/Monkey.cs index 4d74ab3..90c19aa 100644 --- a/Advent Of Code Library/2022/Day 11/Monkey.cs +++ b/AdventOfCode.Solutions/2022/Day 11/Monkey.cs @@ -1,138 +1,138 @@ -namespace AdventOfCode.Solutions._2022.Day_11 -{ - internal class Monkey - { - internal int MonkeyId; - - internal int TotalInspections = 0; - - internal List Items; - - internal int TestDevision; - private int WorryDevision; - internal int lcm; - - private OperationEnum Operation; - - private long? OperationValue; - - private Monkey ThrowTrueMonkey; - private Monkey ThrowFalseMonkey; - - /* - Monkey 0: - Starting items: 79, 98 - Operation: new = old * 19 - Test: divisible by 23 - If true: throw to monkey 2 - If false: throw to monkey 3 - */ - internal Monkey (int monkeyId, int worryDivideNumber, string[] monkeyData) - { - MonkeyId = monkeyId; - WorryDevision = worryDivideNumber; - - Items = monkeyData[1].Split(':')[^1].Split(',').Select(s => Convert.ToInt64(s.Trim())).ToList(); - string[] operation = monkeyData[2].Split(' '); - SetOperation(operation[^2][0], operation[^1]); - SetTestValue(Convert.ToInt32(monkeyData[3].Split(' ')[^1])); - } - - internal void DoTurn(bool calcByWorryDivision = true) - { - for (int worryIndex = 0; worryIndex < Items.Count; worryIndex++) - { - long item = Items[worryIndex]; - item = GetNewWorry(item, calcByWorryDivision); - ThrowToMonkey(item); - TotalInspections++; - } - - Items.Clear(); - } - - internal long GetNewWorry(long oldWorry, bool calcByWorryDivision) - { - long secondValue = OperationValue ?? oldWorry; - - switch (Operation) - { - case OperationEnum.Add: - secondValue = oldWorry + secondValue; - break; - case OperationEnum.Subtract: - secondValue = oldWorry - secondValue; - break; - case OperationEnum.Divide: - secondValue = oldWorry / secondValue; - break; - case OperationEnum.Multiply: - secondValue = oldWorry * secondValue; - break; - } - - if (calcByWorryDivision) - { - return secondValue / WorryDevision; - } - - return secondValue % lcm; - - } - - internal void ThrowToMonkey(long worry) - { - if (worry % TestDevision == 0) - { - ThrowTrueMonkey.Items.Add(worry); - } - else - { - ThrowFalseMonkey.Items.Add(worry); - } - - } - - internal void SetOperation(char operation, string value) - { - switch (operation) - { - case '+': Operation = OperationEnum.Add; - break; - case '-': - Operation = OperationEnum.Subtract; - break; - case '/': - Operation = OperationEnum.Divide; - break; - case '*': - Operation = OperationEnum.Multiply; - break; - } - - if (!value.Equals("old")) - { - OperationValue = Convert.ToInt64(value); - } - } - - internal void SetTestValue(int value) - { - TestDevision = value; - } - - internal void SetThrowTargets(Monkey trueMonkey, Monkey falseMonkey) - { - ThrowTrueMonkey = trueMonkey; - ThrowFalseMonkey = falseMonkey; - } - } - - internal enum OperationEnum - { - Add, - Subtract, - Multiply, - Divide - } -} +namespace AdventOfCode.Solutions._2022.Day_11 +{ + internal class Monkey + { + internal int MonkeyId; + + internal int TotalInspections = 0; + + internal List Items; + + internal int TestDevision; + private int WorryDevision; + internal int lcm; + + private OperationEnum Operation; + + private long? OperationValue; + + private Monkey ThrowTrueMonkey; + private Monkey ThrowFalseMonkey; + + /* + Monkey 0: + Starting items: 79, 98 + Operation: new = old * 19 + Test: divisible by 23 + If true: throw to monkey 2 + If false: throw to monkey 3 + */ + internal Monkey (int monkeyId, int worryDivideNumber, string[] monkeyData) + { + MonkeyId = monkeyId; + WorryDevision = worryDivideNumber; + + Items = monkeyData[1].Split(':')[^1].Split(',').Select(s => Convert.ToInt64(s.Trim())).ToList(); + string[] operation = monkeyData[2].Split(' '); + SetOperation(operation[^2][0], operation[^1]); + SetTestValue(Convert.ToInt32(monkeyData[3].Split(' ')[^1])); + } + + internal void DoTurn(bool calcByWorryDivision = true) + { + for (int worryIndex = 0; worryIndex < Items.Count; worryIndex++) + { + long item = Items[worryIndex]; + item = GetNewWorry(item, calcByWorryDivision); + ThrowToMonkey(item); + TotalInspections++; + } + + Items.Clear(); + } + + internal long GetNewWorry(long oldWorry, bool calcByWorryDivision) + { + long secondValue = OperationValue ?? oldWorry; + + switch (Operation) + { + case OperationEnum.Add: + secondValue = oldWorry + secondValue; + break; + case OperationEnum.Subtract: + secondValue = oldWorry - secondValue; + break; + case OperationEnum.Divide: + secondValue = oldWorry / secondValue; + break; + case OperationEnum.Multiply: + secondValue = oldWorry * secondValue; + break; + } + + if (calcByWorryDivision) + { + return secondValue / WorryDevision; + } + + return secondValue % lcm; + + } + + internal void ThrowToMonkey(long worry) + { + if (worry % TestDevision == 0) + { + ThrowTrueMonkey.Items.Add(worry); + } + else + { + ThrowFalseMonkey.Items.Add(worry); + } + + } + + internal void SetOperation(char operation, string value) + { + switch (operation) + { + case '+': Operation = OperationEnum.Add; + break; + case '-': + Operation = OperationEnum.Subtract; + break; + case '/': + Operation = OperationEnum.Divide; + break; + case '*': + Operation = OperationEnum.Multiply; + break; + } + + if (!value.Equals("old")) + { + OperationValue = Convert.ToInt64(value); + } + } + + internal void SetTestValue(int value) + { + TestDevision = value; + } + + internal void SetThrowTargets(Monkey trueMonkey, Monkey falseMonkey) + { + ThrowTrueMonkey = trueMonkey; + ThrowFalseMonkey = falseMonkey; + } + } + + internal enum OperationEnum + { + Add, + Subtract, + Multiply, + Divide + } +} diff --git a/Advent Of Code Library/2022/Day 12/day-12-input.txt b/AdventOfCode.Solutions/2022/Day 11/day-11-input.txt similarity index 100% rename from Advent Of Code Library/2022/Day 12/day-12-input.txt rename to AdventOfCode.Solutions/2022/Day 11/day-11-input.txt diff --git a/Advent Of Code Library/2022/Day 12/Day12Part1.cs b/AdventOfCode.Solutions/2022/Day 12/Day12Part1.cs similarity index 100% rename from Advent Of Code Library/2022/Day 12/Day12Part1.cs rename to AdventOfCode.Solutions/2022/Day 12/Day12Part1.cs diff --git a/Advent Of Code Library/2022/Day 12/Day12Part2.cs b/AdventOfCode.Solutions/2022/Day 12/Day12Part2.cs similarity index 100% rename from Advent Of Code Library/2022/Day 12/Day12Part2.cs rename to AdventOfCode.Solutions/2022/Day 12/Day12Part2.cs diff --git a/Advent Of Code Library/2022/Day 12/Map.cs b/AdventOfCode.Solutions/2022/Day 12/Map.cs similarity index 100% rename from Advent Of Code Library/2022/Day 12/Map.cs rename to AdventOfCode.Solutions/2022/Day 12/Map.cs diff --git a/Advent Of Code Library/2022/Day 11/day-11-input.txt b/AdventOfCode.Solutions/2022/Day 12/day-12-input.txt similarity index 95% rename from Advent Of Code Library/2022/Day 11/day-11-input.txt rename to AdventOfCode.Solutions/2022/Day 12/day-12-input.txt index 4961e11..bc9319d 100644 --- a/Advent Of Code Library/2022/Day 11/day-11-input.txt +++ b/AdventOfCode.Solutions/2022/Day 12/day-12-input.txt @@ -1,55 +1,55 @@ -Monkey 0: - Starting items: 66, 71, 94 - Operation: new = old * 5 - Test: divisible by 3 - If true: throw to monkey 7 - If false: throw to monkey 4 - -Monkey 1: - Starting items: 70 - Operation: new = old + 6 - Test: divisible by 17 - If true: throw to monkey 3 - If false: throw to monkey 0 - -Monkey 2: - Starting items: 62, 68, 56, 65, 94, 78 - Operation: new = old + 5 - Test: divisible by 2 - If true: throw to monkey 3 - If false: throw to monkey 1 - -Monkey 3: - Starting items: 89, 94, 94, 67 - Operation: new = old + 2 - Test: divisible by 19 - If true: throw to monkey 7 - If false: throw to monkey 0 - -Monkey 4: - Starting items: 71, 61, 73, 65, 98, 98, 63 - Operation: new = old * 7 - Test: divisible by 11 - If true: throw to monkey 5 - If false: throw to monkey 6 - -Monkey 5: - Starting items: 55, 62, 68, 61, 60 - Operation: new = old + 7 - Test: divisible by 5 - If true: throw to monkey 2 - If false: throw to monkey 1 - -Monkey 6: - Starting items: 93, 91, 69, 64, 72, 89, 50, 71 - Operation: new = old + 1 - Test: divisible by 13 - If true: throw to monkey 5 - If false: throw to monkey 2 - -Monkey 7: - Starting items: 76, 50 - Operation: new = old * old - Test: divisible by 7 - If true: throw to monkey 4 +Monkey 0: + Starting items: 66, 71, 94 + Operation: new = old * 5 + Test: divisible by 3 + If true: throw to monkey 7 + If false: throw to monkey 4 + +Monkey 1: + Starting items: 70 + Operation: new = old + 6 + Test: divisible by 17 + If true: throw to monkey 3 + If false: throw to monkey 0 + +Monkey 2: + Starting items: 62, 68, 56, 65, 94, 78 + Operation: new = old + 5 + Test: divisible by 2 + If true: throw to monkey 3 + If false: throw to monkey 1 + +Monkey 3: + Starting items: 89, 94, 94, 67 + Operation: new = old + 2 + Test: divisible by 19 + If true: throw to monkey 7 + If false: throw to monkey 0 + +Monkey 4: + Starting items: 71, 61, 73, 65, 98, 98, 63 + Operation: new = old * 7 + Test: divisible by 11 + If true: throw to monkey 5 + If false: throw to monkey 6 + +Monkey 5: + Starting items: 55, 62, 68, 61, 60 + Operation: new = old + 7 + Test: divisible by 5 + If true: throw to monkey 2 + If false: throw to monkey 1 + +Monkey 6: + Starting items: 93, 91, 69, 64, 72, 89, 50, 71 + Operation: new = old + 1 + Test: divisible by 13 + If true: throw to monkey 5 + If false: throw to monkey 2 + +Monkey 7: + Starting items: 76, 50 + Operation: new = old * old + Test: divisible by 7 + If true: throw to monkey 4 If false: throw to monkey 6 \ No newline at end of file diff --git a/Advent Of Code Library/2023/Day 01/Day01Part1.cs b/AdventOfCode.Solutions/2023/Day 01/Day01Part1.cs similarity index 100% rename from Advent Of Code Library/2023/Day 01/Day01Part1.cs rename to AdventOfCode.Solutions/2023/Day 01/Day01Part1.cs diff --git a/Advent Of Code Library/2023/Day 01/Day01Part2.cs b/AdventOfCode.Solutions/2023/Day 01/Day01Part2.cs similarity index 100% rename from Advent Of Code Library/2023/Day 01/Day01Part2.cs rename to AdventOfCode.Solutions/2023/Day 01/Day01Part2.cs diff --git a/Advent Of Code Library/2023/Day 01/day-01-input.txt b/AdventOfCode.Solutions/2023/Day 01/day-01-input.txt similarity index 100% rename from Advent Of Code Library/2023/Day 01/day-01-input.txt rename to AdventOfCode.Solutions/2023/Day 01/day-01-input.txt diff --git a/Advent Of Code Library/2023/Day 02/Day02Part1.cs b/AdventOfCode.Solutions/2023/Day 02/Day02Part1.cs similarity index 100% rename from Advent Of Code Library/2023/Day 02/Day02Part1.cs rename to AdventOfCode.Solutions/2023/Day 02/Day02Part1.cs diff --git a/Advent Of Code Library/2023/Day 02/Day02Part2.cs b/AdventOfCode.Solutions/2023/Day 02/Day02Part2.cs similarity index 100% rename from Advent Of Code Library/2023/Day 02/Day02Part2.cs rename to AdventOfCode.Solutions/2023/Day 02/Day02Part2.cs diff --git a/Advent Of Code Library/2023/Day 02/day-02-input.txt b/AdventOfCode.Solutions/2023/Day 02/day-02-input.txt similarity index 100% rename from Advent Of Code Library/2023/Day 02/day-02-input.txt rename to AdventOfCode.Solutions/2023/Day 02/day-02-input.txt diff --git a/AdventOfCode.Solutions/2023/Day 03/Day03.cs b/AdventOfCode.Solutions/2023/Day 03/Day03.cs new file mode 100644 index 0000000..cafeb06 --- /dev/null +++ b/AdventOfCode.Solutions/2023/Day 03/Day03.cs @@ -0,0 +1,123 @@ +using AdventOfCode.Core; +using System.Text.RegularExpressions; +using static System.Runtime.InteropServices.JavaScript.JSType; + +namespace AdventOfCode.Solutions._2023 +{ + public partial class Day03(InputReader reader) : IChallange + { + private InputReader _inputReader = reader; + + private class PartNumber + { + public int X { get; set; } + + public int Y { get; set; } + + public string Section { get; set; } = string.Empty; + + public int Length => Section.Length; + + public bool IsDigit() => Section.Length > 1; + + public bool IsPartSymbol() => !IsDigit(); + + public override string ToString() + { + return $"[{Y},{X}] {Section}"; + } + } + + public async Task GetSolutionPart1() + { + List parts = []; + int row = 0; + int total = 0; + await foreach (string line in _inputReader.ReadAsStringLine()) + { + MatchCollection matchCollection = FindPartItems().Matches(line); + parts.AddRange(matchCollection.Select(match => new PartNumber { X = match.Index, Y = row, Section = match.Value })); + row++; + } + + List numbers = parts.Where(p => p.IsDigit()).ToList(); + List symbols = parts.Where(p => p.IsPartSymbol()).ToList(); + + var intersected = numbers.Where(number => GetSection(symbols, number.X - 1, number.Y - 1, number.X + number.Length, number.Y + 1).Any()).ToList(); + + total = numbers.Where(number => GetSection(symbols, number.X - 1, number.Y - 1, number.X + number.Length, number.Y + 1).Any()).Sum(number => int.Parse(number.Section)); + + //Grid grid = await _inputReader.ReadToGrid(); + //int row = 0; + // + //await foreach(string line in _inputReader.ReadAsStringLine()) + //{ + // MatchCollection matchCollection = FindDigits().Matches(line); + // + // foreach (Match match in matchCollection.Cast()) + // { + // var section = grid.GetSection(match.Index - 1, row - 1, match.Index + match.Length, row + 1).ToList(); + // bool isPartNumber = section.Any(n => !(n.Char == '.' || (n.Char >= '0' && n.Char <= '9'))); + // if (isPartNumber) { + // total += int.Parse(match.Value); + // } + // } + // + // row++; + //} + + return total.ToString(); + } + + public async Task GetSolutionPart2() + { + List parts = []; + int row = 0; + int total = 0; + await foreach (string line in _inputReader.ReadAsStringLine()) + { + MatchCollection matchCollection = FindPartItems().Matches(line); + parts.AddRange(matchCollection.Select(match => new PartNumber { X = match.Index, Y = row, Section = match.Value })); + row++; + } + + List numbers = parts.Where(p => p.IsDigit()).ToList(); + List gears = parts.Where(p => p.IsPartSymbol() && p.Section == "*").ToList(); + + foreach (PartNumber gear in gears) + { + // check if there are 2 numbers around + List ratios = GetSection(numbers, gear).ToList(); + + if (ratios.Count != 2) + continue; + + int totalRatio = int.Parse(ratios[0].Section) * int.Parse(ratios[1].Section); + + total += totalRatio; + } + + return total.ToString(); + } + + private IEnumerable GetSection(List toSearch, int fromX, int fromY, int toX, int toY) + { + return toSearch.Where(node => node.X >= fromX && node.X + node.Length <= toX && node.Y >= fromY && node.Y <= toY); + } + + private IEnumerable GetSection(List toSearch, PartNumber source) + { + return toSearch.Where(target => + target.X >= source.X - 1 && + target.X + target.Length <= source.X && + target.Y >= source.Y - 1 && + target.Y <= source.Y + 1); + } + + [GeneratedRegex("(\\d+)", RegexOptions.Compiled)] + private static partial Regex FindDigits(); + + [GeneratedRegex("(\\d+)|([^.])", RegexOptions.Compiled)] + private static partial Regex FindPartItems(); + } +} \ No newline at end of file diff --git a/AdventOfCode.Solutions/2023/Day 03/day-03-input.txt b/AdventOfCode.Solutions/2023/Day 03/day-03-input.txt new file mode 100644 index 0000000..af8dff2 --- /dev/null +++ b/AdventOfCode.Solutions/2023/Day 03/day-03-input.txt @@ -0,0 +1,140 @@ +.......................153..988....502..842.........588.....441.468......481..........314...715.57............................163..992..512. +............805............*......#.............%...............*........=......%......................#......*.............-....#....*..... +........914.........#...617..201.........271.....671......52..898................847..........*230..215......393..%751....537............... +..........#......361..........*...........*............-4.............165..609........922..133...........706..................*....552*127.. +490*..........................350...*...664........806................../..*...514.31...=........../25....%.................83.............. +....245...............805...........467.......449...+..............313*....115....*.......611.343............$...237..229................... +........................*.....150.............*..............8.........511...................*........#.....837.*......*....*............... +435.................688.8..............$......330.................474.......9.......736...........*...787........336...245...446.....916.... +...*.*....920........%................666..90.....786$..221.......*.....173.%.......*........@..25.98.....186#.......................*...... +.718.120..@.............$.931................*...........*....15...10....*.........649....&.542.....................-.......@.......106..... +.............-.......794...................486.........209....*..2........252..........517...................250.519......274............... +...636.....500........................878.......106.........487..*....819........353.........678.........../..-...............539........... +.............................43......*...........$.......44.....881....*...662*...%................407#...612.......452@.286................ +..................................195..543.../.......75..............887.......43...396..................................=.............813.. +........$.735......590.998.............=...862............228......................*................+...%...........979.....500=......*..... +......597..........=...+.........61..................878../....596......*........542../815....567.834..672.=378.....*...&.........#..981.... +...................................*618..998.........*...............716..........................................495.682..62..945.......... +.......915..............156.................$.......298........479........170............985............+90..../.............@.....&7....... +...800*.............246*.........370..............................-.........*....639....*.....362.368.......818................687.......... +.........$.173............383=......*........389......................273....785.....514....=...*....*...........@..............*....446*833 +.433...227...*...-.-...............770.988.................738.523...*....................397....599..499...&..385.........*199.35.......... +...%........40.437..300../....740.........*...................*...........................................192......&....272............*.... +........#.................305.......318.608..609....*..............448......@...959*604....16*...../..............131............=..325.215. +.980...85....*48......883.............@..............663.................128..................944.420...203.....................381......... +..........887............*....434........725................958......367......178..........................@.779.........................986 +.......................591...*......964.*....713.140..........*..698....*......................772.......................914........223..... +...........960.....*....................80.....#..%....456..824....*...138...939.........362*......488...572........663..&..........*....... +.......+.....*...645.............%12.....................*.........692...............922.....902..@.................*........27..542........ +...792..242.702.........256..668..............613*479...329...................134#....*...................*545...375........................ +.......................&......*.............&..........................298.........696.................844.....=....................184..... +......886=..................129....187.......850..*.....&................*...............358...130............500................@.....*.... +.............*54..112.............*..............791..215...787.........437..889..............*........584........../226......366...483..... +.......47..........*....826.500..48......665..................*.................*.377....#...49.......$..................................... +.196...*..........815......*..............*.....*...........571........297*...153.*....416...............+.....73...126.............111..... +.......164............547#................69.503.743............108...............22......../70....36.....470................516....*....... +....................................634................&.357......*...................275.........+................592......%....52.204..... +....#943....843............544.......-.....96*139...640........694................@.........558......................*...........*.......104 +..............*....731.......*...382...................................../...%557..857......*....-................716..638./165...338....... +......926....342../..........861............/......................#...768...................569..192...................*................... +..272....................500.......*.........784......558..38.....786..........238.932%................/...827....841............76......... +.....*25....=..780.74...........457....%..%.......806........*........&........*...........+..........53..*..........%.............*........ +..99.....697...$....+................601.757.600...........751........801......795..998....362...........431......&............797.860...... +....*...................50.579...............&...-.878.....................586.....*............587..216.......321...783.................... +...859.................@.....+.317/............34../...499.....904.991.......$....938......337@...*..#.................*.............130*312 +............707.266.....................156..9............*.......*..............................880.......787.........102.................. +.........*.....*................938*743...*.*..............195.........425..........869*.....448..........*.....73.689.....48..469.......... +......568.164....938........................964.......899......641.....*........930.............*...891....104........*...&.......*719...... +....................*..................#...........+..-...381......36.749...744..*......659...935......+..............694.....370........... +........174........460............+..435........893........%................+.....500......$.............#......397.............*...549.677. +....981.*.....&355.....960.......963..................543#.........................................971...483....%............428.....=...... +354..*................*.....752..................69........676..54.......531*......78....877..-950....%............346...........699........ +......265.....#......959.................846.......*...93............263.....974....=.......*............&........................*......... +............857...........527............../.......29....@.846.......*.....................768..134&...571..........302...........512....... +....$254.........397......*............./....................%....128.........*984.....693..................991...+...*.@....@...........228 +............335...*.....751......626.699............$118..............991..............$....................*...327.93..508.301......348.... +....387........@.266..............*.......................-...........*.......%...................260....756................................ +....*.....817..................726...391.....112..........273..997...197....667......./......932*....$........290...............711......560 +...488.....&....961.....170.........*..........*................*.........*........883..825......71..............&...215...........*.766.... +...............+.........#....$.....600.&.......674.42.................730.998.........*..................139.........*.........461....=.... +...#97...........817........86..........155..............759.....200.............827...163..........................499..................... +.....................#.........................793*722...........................$..............&....725&......................442.......... +.............812....613.....892..........................464......430..%.....462.....%.......599.............555..204....219......*637...... +...544........./............&...............................*.......*.840.......*...994.797........52.........*....*..........739........... +....=..................................713.304...161........186.................824.......-....=....*.......118.844..113......*.....872..... +......................75.963......244.....*.....*.......466..........590....................208....363...............*.....872.............. +.............391.....*...............*.......843......#..........184..-.................................441......448.597.................... +979......416......114................306.%.........719.....792......$...........................#..........*..............603.989.914*...... +.........-..................975..670.....890...621...........*..........145..659...369=.@978....935........938...............*........107... +................259..%632....=...................*......173...871........*...................4..........*..........&108.........*281........ +...............*................326.....732...528.../....#.............698.............316..*........188.888.................918............ +..512........507...............*...........*........440.........................938......./.254..313...............................422...... +....*............300.........430..354$.....884.701.......%....368............../....@480...........*..142.............305...145.61......106. +.363..939.639..................................$...../....704.....835@...-776....................655.........645......*......*....*892...... +.........*..........*338................../........741........................113..895...............%..403.....*..40..992..2............... +.................986...........927..%449.17............................182....*.....=......870......899........665.#.................949.189 +...841.........................*.......................................*...849...........=....*295.........420..............441.882......... +......$..+.............124...993..........*...........*................365..........79.364................*.............414*.....-.....360.. +........159...........*...........457$....199......960.967...&...................................+......181.....+.......................*... +.....................859...................................962.............912....#......330.....168...........904.....958*....213*583..49.. +........%.........*..........421..340*196..892.........409.................*....488.645...*..........#...................................... +.....802........116...........*...........................*...227........791.........$....203.....963..418................599+..........744. +..............#.....-966.23.94...58..283...........476....722.......730...........................................@..700.......%788......... +240%..........844..................*.-.........486............307............#49...288........&.329.............61..*.....................95 +.........#............148..446...........402/..........256.......................&..........573..*...................319.......763.......... +......936..............*...%.................................-....709...371...955..352............553.629....445..................*......... +.121......445.347...455.......=....#....92..................367..*......*............@........881........*..*....267/.....-89......843.*782. +......519.=.....*.........401.996.452...-.......-387.886.........982...149..910%..........81..-.........653..407......819.......@........... +.....*.......950...448#....*...............&691......$......................................*....538..............681*.........560.......... +.....25....................60............*......................304*863...../.............103......*.........811..........923.......426..... +.800..................../................974..............255..............958....738..............465.........*......181...+........./..... +....*.....-......824....782........90...........+505.......*....903...................544.712.826...........800..........*.................. +...408..123...-.........................................557.......*....................@.....*....561.743............310..642...97*475...... +...............900.#494.....915.624............../..............508.....431.*500.........986...../......=....187........*................... +...........................*......*....#741.@957.979.*................/..%................%.............................218.805......505*... +...........................59.....595.................948...+........885.....*808...554.........70......827=.............................690 +...95........+......455.....................................776...........795......=..............&...$........349...............621*80..... +...*....../.793..$...#.....................842..........898.........729...................698.......273...704...*.......451..%.............. +.......340......911......865.....876..........-...........*...%......*....676*498..424...-.......=.........*........241..#...967.......323.. +........................-...........*271..578...........734..8..692..435....................698.548.................@...................*... +.....=......*..................131...........=..=..............*.............523.659...221...+........................468..263..395.408..757 +.....236....661...565*...........#...............228............287...448.......*......&......................=.........#.+........*........ +......................982.................$..........403*317.............*103.................454...#...311....588...................105.... +...72...............................246..991...../...........12................%.........271...=....668.................................*... +.......348...259......$..../384.221...............873.......*.....560....&...686............*..................241............763........884 +........*...+..........848.................=........................*.....76......*....889..417.404...............&...538.663..=......61.... +.......446....948..805.....615.....303+.372..........893.......945...849.........861....*........*...187.980...&....../...........838.+..... +...453...............*....*.....................357...../.........+....................506....129..@.......*..633.822............*.......... +......*188........495....732............635*.....$............219........65....475................811...231..........*..332%...212.......... +.................................*..........575.....-....591...*...420.........*...............................897.317.............165...762 +.............764..410.............438....*..........588....*.245..%......*.....468..........32..-714...456.........................*....*... +..............*.......................516.552...366......416........166...552.................*.............../..126.........396.386....921. +.......&.............67&........468................*.............................403.221.......433.....411..299..........457*............... +.....539.......*287.............*............657/.457..............614........34*......*.....$......12*.........693......................... +............908......@602..176..358..778...............72...-..............$..........161.579..................*................571*602..... +...........................*............*799...........*.....118........788....689................$....../702..493.......117............%... +.................337..496..504.......................519............#..........=....744........782...................625.*.......499.....576 +.......459..%..............................................28.....398...............*..............*19....#935.........$..845......#........ +.............707.....................992........289...481+...*..................3..234....822$.......................................#...... +..513.914*.........161......664.....*..........@..............922......$.........*......................330..............@...........798.... +..........378.................*..258...............219+.313.........836.....=226.566.....748....&...147*......872.......786..538.446........ +.....*827...........907....844.............684..........@..................................*..263............../....8..............=...*.... +835........$...88......*.........308.........*.....161.....621*327..-184....333.........@.473.....205..................................872.. +...*....340.............744........-.........961....../........................*449...740........*................867.427..251.............. +..988........@...................................................765..........................743......228...............*........942....... +.............125..#...........406.........%.....837.................*.....609*.........%..........644...=..465*643....880..509...*.......453 +....544..........480.............=.........274.....*..148..583...821..........880.....492....535...@.......................*............*... +.....$.......306................................287....#..*...........647.....................$........-......166.714....942..675.....657... +................*....................673...780...........620..........*.........&..........=......997.465..........$.............*.......... +.456........920..855.913..............*.../.....325*316.......6.......208....486........715.....=...%.............................67........ +......*178..+.............686.59....871.................$......*.............................149..............238........634................ +....56.........385...648*...............*968..&.......732.....921.467........*.........479.........695*284.../..........*................... +............56.....$.....675..746#.............384.................*......451.709................................%..939..265.........290*891 +................501.......................620.............900.......825.................258...387......21*40...273...*...................... +.......532..................................*....*....956....=....................711.........&.....................415.307....411......9... +..............................314../......692.214.718.............762*461.....844*.....&.............973.675...80.................*143...... +...........365.......460.329.@......476....................................*..........926.....799...*.............-......................... +..............*.297...*...*.........................753........700......473.765..............*....967........111.629.932....125............. +.......+...261...&.......786.283....695.....486.....*......565.+................536...../....380....../124..%........*.........%............ +......339..............*..............*....*.......996.......-.....+..............*......752......................@...............-......... +.......................716...........551.631........................279..555.....373...................691......114.215............515...... \ No newline at end of file diff --git a/Advent Of Code Library/AdventOfCode.Solutions.csproj b/AdventOfCode.Solutions/AdventOfCode.Solutions.csproj similarity index 59% rename from Advent Of Code Library/AdventOfCode.Solutions.csproj rename to AdventOfCode.Solutions/AdventOfCode.Solutions.csproj index b12121c..71985d2 100644 --- a/Advent Of Code Library/AdventOfCode.Solutions.csproj +++ b/AdventOfCode.Solutions/AdventOfCode.Solutions.csproj @@ -8,7 +8,13 @@ - + + + + + + Always + diff --git a/Advent Of Code Library/Usings.cs b/AdventOfCode.Solutions/Usings.cs similarity index 100% rename from Advent Of Code Library/Usings.cs rename to AdventOfCode.Solutions/Usings.cs diff --git a/AdventOfCode.Solutions/day-00-input.txt b/AdventOfCode.Solutions/day-00-input.txt new file mode 100644 index 0000000..624ea4f --- /dev/null +++ b/AdventOfCode.Solutions/day-00-input.txt @@ -0,0 +1,10 @@ +467..114.. +...*...... +..35..633. +......#... +617*...... +.....+.58. +..592..... +......755. +...$.*.... +.664.598.. \ No newline at end of file