part one complete

This commit is contained in:
2025-12-05 12:01:03 -05:00
parent 842e9be900
commit c4ad0b41e8
2 changed files with 32 additions and 2 deletions

View File

@@ -28,6 +28,10 @@
<Content Include="Input\DayFour.txt"> <Content Include="Input\DayFour.txt">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory> <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content> </Content>
<None Remove="Input\DayFive.txt" />
<Content Include="Input\DayFive.txt">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
</ItemGroup> </ItemGroup>
</Project> </Project>

View File

@@ -1,9 +1,35 @@
namespace AdventOfCode2025; using AdventOfCode2025.Utils;
using Range = AdventOfCode2025.Utils.Range;
namespace AdventOfCode2025;
public class Cafeteria : IAdventSolution public class Cafeteria : IAdventSolution
{ {
public AdventSolution Solve(string input) public AdventSolution Solve(string input)
{ {
throw new NotImplementedException(); var lines = input.SplitLines();
var ranges = new HashSet<Range>();
var startIndex = 0;
while (lines[startIndex].Contains("-"))
{
var line = lines[startIndex++];
var parts = line.Split('-');
ranges.Add(new(ulong.Parse(parts[0]), ulong.Parse(parts[1])));
}
var fresh = 0;
for(; startIndex < lines.Length; startIndex++)
{
var line = lines[startIndex++];
if (line.Contains('-'))
continue;
var num = ulong.Parse(line);
if(ranges.Any(x => x.Min <= num && num <= x.Max)) fresh++;
}
return new AdventSolution(fresh.ToString(), null);
} }
} }