Skip to content

Commit

Permalink
Update Smab.Helpers v1.7.19
Browse files Browse the repository at this point in the history
  • Loading branch information
smabuk committed Dec 10, 2024
1 parent 984316d commit 1f7c5bf
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 11 deletions.
2 changes: 1 addition & 1 deletion Directory.Packages.props
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,6 @@
<PackageVersion Include="coverlet.collector" Version="6.0.2" />
<PackageVersion Include="Shouldly" Version="4.2.1" />
<PackageVersion Include="AngleSharp" Version="1.1.2" />
<PackageVersion Include="Smab.Helpers" Version="1.7.17" />
<PackageVersion Include="Smab.Helpers" Version="1.7.19" />
</ItemGroup>
</Project>
15 changes: 5 additions & 10 deletions Solutions/2024/Day10.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ public static partial class Day10
[Init]
public static void FindAllTheTrails(string[] input)
{
int[,] lavaMap = input.Select(i => i.AsHeights()).ToList().To2dArray();
int[,] lavaMap = input.Select(i => i.AsHeights()).To2dArray();

_allRoutes = [..
lavaMap
Expand All @@ -24,16 +24,10 @@ public static void FindAllTheTrails(string[] input)
];
}

public static int Part1(string[] _)
{
return _allRoutes
.Select(trail => (trail.StartPoint, trail.EndPoint))
.Distinct()
.Count();
}

public static int Part1(string[] _) => _allRoutes.DistinctBy(t => (t.StartPoint, t.EndPoint)).Count();
public static int Part2(string[] _) => _allRoutes.Count;


private static IEnumerable<Trail> HikeToSummit(this int[,] map, Trail trail)
{
foreach (Trail nextTrail in map.NextPositions(trail)) {
Expand All @@ -57,7 +51,8 @@ private static IEnumerable<Trail> NextPositions(this int[,] map, Trail trail)
.Where(next => next.Value == trail.End + 1)
.Select(next => trail with { EndPoint = next.Index, End = next.Value, Route = [.. trail.Route, next] });

private static List<int> AsHeights(this string s) => [.. s.Select(x => char.IsAsciiDigit(x) ? int.Parse($"{x}", null) : int.MinValue)];
private static IEnumerable<int> AsHeights(this string s)
=> [.. s.Select(x => char.IsAsciiDigit(x) ? int.Parse($"{x}") : int.MinValue)];

public record Trail(int Start, int End, Point StartPoint, Point EndPoint, List<Point> Route);

Expand Down

0 comments on commit 1f7c5bf

Please sign in to comment.