Piotr Czajkowski vor 20 Stunden
Ursprung
Commit
ad1dd585fa
1 geänderte Dateien mit 8 neuen und 6 gelöschten Zeilen
  1. 8 6
      20/code.go

+ 8 - 6
20/code.go

@@ -89,16 +89,18 @@ func hike(start *Point, matrix [][]byte, xMax, yMax int, cheat bool, cheats map[
 	for len(moves) > 0 {
 		current := moves[0]
 		moves = moves[1:]
-		if matrix[current.y][current.x] == 'E' && (current.cost <= cost || cheat && current.cost < bestWithoutCheating) {
-			cost = current.cost
-			if cheat {
-				saving := bestWithoutCheating - current.cost
-				savings[saving]++
+		if matrix[current.y][current.x] == 'E' {
+			if current.cost <= cost || cheat && current.cost < bestWithoutCheating {
+				cost = current.cost
+				if cheat && current.cheatedAt != nil {
+					saving := bestWithoutCheating - current.cost
+					savings[saving]++
 
-				if current.cheatedAt != nil {
 					cheats[current.cheatedAt.key()] = true
 				}
 			}
+
+			continue
 		}
 
 		newMoves := getMoves(current, matrix, xMax, yMax, cheat, cheats)