part one complete
This commit is contained in:
@@ -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>
|
||||||
|
|||||||
@@ -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);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user