public override async ValueTask <string> Solve_1() { var dest = _grid.BottomRight; var s = new AStarSearch <Point>(null, Expand); var path = s.FindFirst(new Point(0, 0), x => x == dest, x => x.ManhattanDistTo(dest)) !; var totalRisk = path.Cost; return(totalRisk.ToString()); IEnumerable <(Point node, float cost)> Expand(Point p) { foreach (var n in _grid.Get4NeighborsOf(p)) { yield return(n, _grid[n] - '0');
private static char Step(FiniteGrid2D <char> map, Point p) { var neighborCount = map.Get4NeighborsOf(p).Count(n => map[n] == '#'); return(StepChar(map[p], neighborCount)); }