Piotr Czajkowski 22 hours ago
parent
commit
9628e0e572
1 changed files with 4 additions and 0 deletions
  1. 4 0
      20/code.go

+ 4 - 0
20/code.go

@@ -103,6 +103,10 @@ func hike(start *Point, matrix [][]byte, xMax, yMax int, cheat bool, cheats map[
 
 		newMoves := getMoves(current, matrix, xMax, yMax, cheat, cheats)
 		for _, newMove := range newMoves {
+			if cheat && newMove.cost >= bestWithoutCheating {
+				continue
+			}
+
 			if visited[newMove.key()] == 0 || visited[newMove.key()] >= newMove.cost {
 				moves = append(moves, newMove)
 				visited[newMove.key()] = newMove.cost