Compare commits

...

4 Commits

Author SHA1 Message Date
1214dcadfe improved time complexity from exponential to linear time 2025-12-03 23:04:27 -05:00
e93bf9ecd7 part 1 brute forced 2025-12-03 13:06:55 -05:00
4cf8f15e14 extension method to split string into lines 2025-12-03 12:50:49 -05:00
633a9d9248 prepping for day two 2025-12-03 12:50:31 -05:00
5 changed files with 56 additions and 3 deletions

View File

@@ -20,6 +20,10 @@
<Content Include="Input\DayTwo.txt">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
<None Remove="Input\DayThree.txt" />
<Content Include="Input\DayThree.txt">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
</ItemGroup>
</Project>

35
AdventOfCode2025/Lobby.cs Normal file
View File

@@ -0,0 +1,35 @@
using System.Runtime.InteropServices.JavaScript;
using AdventOfCode2025.Utils;
namespace AdventOfCode2025;
public class Lobby : IAdventSolution
{
public AdventSolution Solve(string input)
{
var lines = input.SplitLines();
var total = 0;
foreach (var line in lines)
{
var first = '0';
var second = '0';
for (var i = 0; i < line.Length; i++)
{
if (i != line.Length - 1 && line[i] > first)
{
first = line[i];
second = line[i + 1];
}
else if (line[i] > second)
{
second = line[i];
}
}
total += int.Parse($"{first}{second}");
}
return new AdventSolution(total.ToString(), null);
}
}

View File

@@ -7,3 +7,6 @@ AdventSolver<SecretEntrance>.Solve(dayOneInput, 1, "Secret Entrance");
var dayTwoInput = await File.ReadAllTextAsync("./Input/DayTwo.txt");
AdventSolver<GiftShop>.Solve(dayTwoInput, 2, "Gift Shop");
var dayThreeInput = await File.ReadAllTextAsync("./Input/DayThree.txt");
AdventSolver<Lobby>.Solve(dayThreeInput, 3, "Lobby");

View File

@@ -1,10 +1,12 @@
namespace AdventOfCode2025;
using AdventOfCode2025.Utils;
namespace AdventOfCode2025;
public class SecretEntrance : IAdventSolution
{
public AdventSolution Solve(string input)
{
var lines = input.Split('\n', StringSplitOptions.RemoveEmptyEntries | StringSplitOptions.TrimEntries);
var lines = input.SplitLines();
var current = 50;
var password = 0;

View File

@@ -0,0 +1,9 @@
namespace AdventOfCode2025.Utils;
public static class StringExtensions
{
public static string[] SplitLines(this string input)
{
return input.Split('\n', StringSplitOptions.RemoveEmptyEntries | StringSplitOptions.TrimEntries);
}
}