Rebuild the whole project
This commit is contained in:
parent
dd2d9afa07
commit
89486fde35
29
2022.csproj
29
2022.csproj
@ -1,29 +0,0 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<OutputType>Exe</OutputType>
|
||||
<TargetFramework>net6.0</TargetFramework>
|
||||
<RootNamespace>2022</RootNamespace>
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
<Nullable>enable</Nullable>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<Compile Remove="Day 01\obj\**" />
|
||||
<EmbeddedResource Remove="Day 01\obj\**" />
|
||||
<None Remove="Day 01\obj\**" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<None Update="Day 01\day-01-input.txt">
|
||||
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
|
||||
</None>
|
||||
<None Update="Day 02\day-02-input.txt">
|
||||
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
|
||||
</None>
|
||||
<None Update="Day 03\day-03-input.txt">
|
||||
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
|
||||
</None>
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
15
Advend Of Code Runner/Advent Of Code Runner.csproj
Normal file
15
Advend Of Code Runner/Advent Of Code Runner.csproj
Normal file
@ -0,0 +1,15 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<OutputType>Exe</OutputType>
|
||||
<TargetFramework>net6.0</TargetFramework>
|
||||
<RootNamespace>AdventOFCodeRunner</RootNamespace>
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
<Nullable>enable</Nullable>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\Advent Of Code Library\Advent Of Code Library.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
6
Advend Of Code Runner/Program.cs
Normal file
6
Advend Of Code Runner/Program.cs
Normal file
@ -0,0 +1,6 @@
|
||||
using Day_03.Day_03;
|
||||
|
||||
byte[] dataArray = File.ReadAllBytes(Day03.InputPath);
|
||||
|
||||
Console.WriteLine($"Max value: {Day03.GetPart2(dataArray)}");
|
||||
Console.ReadKey(true);
|
||||
@ -1,29 +1,29 @@
|
||||
namespace Day_01.Day_01
|
||||
{
|
||||
internal class Day01
|
||||
{
|
||||
private static string inputPath = "Day 01/day-01-input.txt";
|
||||
|
||||
internal static int GetPart1()
|
||||
{
|
||||
return File.ReadAllText(inputPath)
|
||||
.TrimEnd()
|
||||
.Split(Environment.NewLine + Environment.NewLine)
|
||||
.Select(s => s.Split(Environment.NewLine)
|
||||
.Sum(Convert.ToInt32))
|
||||
.MaxBy(v => v);
|
||||
}
|
||||
|
||||
internal static int GetPart2()
|
||||
{
|
||||
return File.ReadAllText(inputPath)
|
||||
.TrimEnd()
|
||||
.Split(Environment.NewLine + Environment.NewLine)
|
||||
.Select(s => s.Split(Environment.NewLine)
|
||||
.Sum(Convert.ToInt32))
|
||||
.OrderByDescending(v => v)
|
||||
.Take(3)
|
||||
.Sum();
|
||||
}
|
||||
}
|
||||
}
|
||||
namespace Day_01.Day_01
|
||||
{
|
||||
public class Day01
|
||||
{
|
||||
private static string inputPath = "Day 01/day-01-input.txt";
|
||||
|
||||
public static int GetPart1()
|
||||
{
|
||||
return File.ReadAllText(inputPath)
|
||||
.TrimEnd()
|
||||
.Split(Environment.NewLine + Environment.NewLine)
|
||||
.Select(s => s.Split(Environment.NewLine)
|
||||
.Sum(Convert.ToInt32))
|
||||
.MaxBy(v => v);
|
||||
}
|
||||
|
||||
public static int GetPart2()
|
||||
{
|
||||
return File.ReadAllText(inputPath)
|
||||
.TrimEnd()
|
||||
.Split(Environment.NewLine + Environment.NewLine)
|
||||
.Select(s => s.Split(Environment.NewLine)
|
||||
.Sum(Convert.ToInt32))
|
||||
.OrderByDescending(v => v)
|
||||
.Take(3)
|
||||
.Sum();
|
||||
}
|
||||
}
|
||||
}
|
||||
File diff suppressed because it is too large
Load Diff
@ -1,81 +1,81 @@
|
||||
namespace Day_02.Day_02
|
||||
{
|
||||
internal class Day02
|
||||
{
|
||||
private static string inputPath = "Day 02/day-02-input.txt";
|
||||
|
||||
private static int Win = 6, Draw = 3, Lost = 0, Rock = 1, Paper = 2, Scissors = 3;
|
||||
|
||||
private static string OpponentRock = "A", OpponentPaper = "B", OpponentScissors = "C",
|
||||
PlayRock = "X", PlayPaper = "Y", PlayScissors = "Z",
|
||||
PlayWin = "Z", PlayDraw = "Y", PlayLose = "X";
|
||||
|
||||
private static Dictionary<string, int> PossibleScores;
|
||||
|
||||
private static void BuildScoreDic()
|
||||
{
|
||||
if (PossibleScores == null)
|
||||
{
|
||||
PossibleScores = new Dictionary<string, int>
|
||||
{
|
||||
// Rock combos
|
||||
{ OpponentRock + " " + PlayPaper, Paper + Win }, // win
|
||||
{ OpponentRock + " " + PlayRock, Rock + Draw }, // draw
|
||||
{ OpponentRock + " " + PlayScissors, Scissors + Lost }, // lose
|
||||
|
||||
// Paper
|
||||
{ OpponentPaper + " " + PlayScissors, Scissors + Win }, // win
|
||||
{ OpponentPaper + " " + PlayPaper, Paper + Draw }, // draw
|
||||
{ OpponentPaper + " " + PlayRock, Rock + Lost }, // lose
|
||||
|
||||
// Scissors
|
||||
{ OpponentScissors + " " + PlayRock, Rock + Win }, // win
|
||||
{ OpponentScissors + " " + PlayScissors, Scissors + Draw }, // draw
|
||||
{ OpponentScissors + " " + PlayPaper, Paper + Lost } // lose
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
private static void BuildWinDrawLoseTable()
|
||||
{
|
||||
if (PossibleScores == null)
|
||||
{
|
||||
PossibleScores = new Dictionary<string, int>
|
||||
{
|
||||
// Rock combos
|
||||
{ OpponentRock + " " + PlayWin, Paper + Win }, // win
|
||||
{ OpponentRock + " " + PlayDraw, Rock + Draw }, // draw
|
||||
{ OpponentRock + " " + PlayLose, Scissors + Lost }, // lose
|
||||
|
||||
// Paper
|
||||
{ OpponentPaper + " " + PlayWin, Scissors + Win }, // win
|
||||
{ OpponentPaper + " " + PlayDraw, Paper + Draw }, // draw
|
||||
{ OpponentPaper + " " + PlayLose, Rock + Lost }, // lose
|
||||
|
||||
// Scissors
|
||||
{ OpponentScissors + " " + PlayWin, Rock + Win }, // win
|
||||
{ OpponentScissors + " " + PlayDraw, Scissors + Draw }, // draw
|
||||
{ OpponentScissors + " " + PlayLose, Paper + Lost } // lose
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
private static int GetScore(string input) => PossibleScores[input];
|
||||
|
||||
internal static int GetPart1()
|
||||
{
|
||||
BuildScoreDic();
|
||||
return File.ReadAllLines(inputPath)
|
||||
.Select(GetScore)
|
||||
.Sum();
|
||||
}
|
||||
|
||||
internal static int GetPart2()
|
||||
{
|
||||
BuildWinDrawLoseTable();
|
||||
return File.ReadAllLines(inputPath)
|
||||
.Select(GetScore)
|
||||
.Sum();
|
||||
}
|
||||
}
|
||||
}
|
||||
namespace Day_02.Day_02
|
||||
{
|
||||
public class Day02
|
||||
{
|
||||
private static string inputPath = "Day 02/day-02-input.txt";
|
||||
|
||||
private static int Win = 6, Draw = 3, Lost = 0, Rock = 1, Paper = 2, Scissors = 3;
|
||||
|
||||
private static string OpponentRock = "A", OpponentPaper = "B", OpponentScissors = "C",
|
||||
PlayRock = "X", PlayPaper = "Y", PlayScissors = "Z",
|
||||
PlayWin = "Z", PlayDraw = "Y", PlayLose = "X";
|
||||
|
||||
private static Dictionary<string, int> PossibleScores;
|
||||
|
||||
private static void BuildScoreDic()
|
||||
{
|
||||
if (PossibleScores == null)
|
||||
{
|
||||
PossibleScores = new Dictionary<string, int>
|
||||
{
|
||||
// Rock combos
|
||||
{ OpponentRock + " " + PlayPaper, Paper + Win }, // win
|
||||
{ OpponentRock + " " + PlayRock, Rock + Draw }, // draw
|
||||
{ OpponentRock + " " + PlayScissors, Scissors + Lost }, // lose
|
||||
|
||||
// Paper
|
||||
{ OpponentPaper + " " + PlayScissors, Scissors + Win }, // win
|
||||
{ OpponentPaper + " " + PlayPaper, Paper + Draw }, // draw
|
||||
{ OpponentPaper + " " + PlayRock, Rock + Lost }, // lose
|
||||
|
||||
// Scissors
|
||||
{ OpponentScissors + " " + PlayRock, Rock + Win }, // win
|
||||
{ OpponentScissors + " " + PlayScissors, Scissors + Draw }, // draw
|
||||
{ OpponentScissors + " " + PlayPaper, Paper + Lost } // lose
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
private static void BuildWinDrawLoseTable()
|
||||
{
|
||||
if (PossibleScores == null)
|
||||
{
|
||||
PossibleScores = new Dictionary<string, int>
|
||||
{
|
||||
// Rock combos
|
||||
{ OpponentRock + " " + PlayWin, Paper + Win }, // win
|
||||
{ OpponentRock + " " + PlayDraw, Rock + Draw }, // draw
|
||||
{ OpponentRock + " " + PlayLose, Scissors + Lost }, // lose
|
||||
|
||||
// Paper
|
||||
{ OpponentPaper + " " + PlayWin, Scissors + Win }, // win
|
||||
{ OpponentPaper + " " + PlayDraw, Paper + Draw }, // draw
|
||||
{ OpponentPaper + " " + PlayLose, Rock + Lost }, // lose
|
||||
|
||||
// Scissors
|
||||
{ OpponentScissors + " " + PlayWin, Rock + Win }, // win
|
||||
{ OpponentScissors + " " + PlayDraw, Scissors + Draw }, // draw
|
||||
{ OpponentScissors + " " + PlayLose, Paper + Lost } // lose
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
private static int GetScore(string input) => PossibleScores[input];
|
||||
|
||||
public static int GetPart1()
|
||||
{
|
||||
BuildScoreDic();
|
||||
return File.ReadAllLines(inputPath)
|
||||
.Select(GetScore)
|
||||
.Sum();
|
||||
}
|
||||
|
||||
public static int GetPart2()
|
||||
{
|
||||
BuildWinDrawLoseTable();
|
||||
return File.ReadAllLines(inputPath)
|
||||
.Select(GetScore)
|
||||
.Sum();
|
||||
}
|
||||
}
|
||||
}
|
||||
File diff suppressed because it is too large
Load Diff
@ -2,11 +2,11 @@
|
||||
|
||||
namespace Day_03.Day_03
|
||||
{
|
||||
internal class Day03
|
||||
public class Day03
|
||||
{
|
||||
public static string InputPath = "Day 03/day-03-input.txt";
|
||||
|
||||
internal static string GetPart1(byte[] data)
|
||||
public static string GetPart1(byte[] data)
|
||||
{
|
||||
string[] rucksackData = Encoding.UTF8.GetString(data).Split(Environment.NewLine);
|
||||
int priorityCount = 0;
|
||||
@ -24,7 +24,7 @@ namespace Day_03.Day_03
|
||||
return priorityCount.ToString();
|
||||
}
|
||||
|
||||
internal static string GetPart2(byte[] data)
|
||||
public static string GetPart2(byte[] data)
|
||||
{
|
||||
string[] rucksackData = Encoding.UTF8.GetString(data).Split(Environment.NewLine);
|
||||
int priorityCount = 0;
|
||||
10
Advent Of Code Library/Advent Of Code Library.csproj
Normal file
10
Advent Of Code Library/Advent Of Code Library.csproj
Normal file
@ -0,0 +1,10 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFramework>net6.0</TargetFramework>
|
||||
<RootNamespace>Advent_Of_Code_Library</RootNamespace>
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
<Nullable>enable</Nullable>
|
||||
</PropertyGroup>
|
||||
|
||||
</Project>
|
||||
@ -1,9 +1,11 @@
|
||||
|
||||
Microsoft Visual Studio Solution File, Format Version 12.00
|
||||
# Visual Studio Version 17
|
||||
VisualStudioVersion = 17.3.32922.545
|
||||
VisualStudioVersion = 17.4.33103.184
|
||||
MinimumVisualStudioVersion = 10.0.40219.1
|
||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "2022", "2022.csproj", "{10D21159-084F-4D2B-9254-1BC9D86E60F9}"
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Advent Of Code Runner", "Advend Of Code Runner\Advent Of Code Runner.csproj", "{6DCDC513-AF72-4029-932A-A0079BB5422B}"
|
||||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Advent Of Code Library", "Advent Of Code Library\Advent Of Code Library.csproj", "{33CC3924-F18E-4B88-9989-A7A9077B9AC4}"
|
||||
EndProject
|
||||
Global
|
||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||
@ -11,15 +13,19 @@ Global
|
||||
Release|Any CPU = Release|Any CPU
|
||||
EndGlobalSection
|
||||
GlobalSection(ProjectConfigurationPlatforms) = postSolution
|
||||
{10D21159-084F-4D2B-9254-1BC9D86E60F9}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{10D21159-084F-4D2B-9254-1BC9D86E60F9}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{10D21159-084F-4D2B-9254-1BC9D86E60F9}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{10D21159-084F-4D2B-9254-1BC9D86E60F9}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{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
|
||||
EndGlobalSection
|
||||
GlobalSection(SolutionProperties) = preSolution
|
||||
HideSolutionNode = FALSE
|
||||
EndGlobalSection
|
||||
GlobalSection(ExtensibilityGlobals) = postSolution
|
||||
SolutionGuid = {716D4A39-3ED5-4047-8761-79BF9B24FB61}
|
||||
SolutionGuid = {D5D52D1F-5A13-43B7-BFC7-773C0E4623D7}
|
||||
EndGlobalSection
|
||||
EndGlobal
|
||||
|
||||
14
Program.cs
14
Program.cs
@ -1,14 +0,0 @@
|
||||
using Day_03.Day_03;
|
||||
using System.Text;
|
||||
|
||||
byte[] data = Encoding.UTF8.GetBytes(@"vJrwpWtwJgWrhcsFMMfFFhFp
|
||||
jqHRNqRjqzjGDLGLrsFMfFZSrLrFZsSL
|
||||
PmmdzqPrVvPwwTWBwg
|
||||
wMqvLMZHhHMvwLHjbvcjnnSBnvTQFn
|
||||
ttgJtRGJQctTZtZT
|
||||
CrZsJsPPZsGzwwsLwLmpwMDw");
|
||||
|
||||
byte[] dataArray = File.ReadAllBytes(Day03.InputPath);
|
||||
|
||||
Console.WriteLine($"Max value: {Day03.GetPart2(dataArray)}");
|
||||
Console.ReadKey(true);
|
||||
Loading…
Reference in New Issue
Block a user