Piotr Czajkowski 1 سال پیش
والد
کامیت
6b3ed266ec
1فایلهای تغییر یافته به همراه2 افزوده شده و 3 حذف شده
  1. 2 3
      17/code.go

+ 2 - 3
17/code.go

@@ -227,10 +227,9 @@ func calculate(board [][]int, minMoves int, maxMoves int) int {
 		successors := getDestinations(board, height, width, current, minMoves, maxMoves)
 		for i := range successors {
 			v := Visited{pos: successors[i].pos, direction: successors[i].direction}
-			newCost := successors[i].cost
 			value, ok := explored[v]
-			if !ok || value > newCost {
-				explored[v] = newCost
+			if !ok || value > successors[i].cost {
+				explored[v] = successors[i].cost
 				frontier = append(frontier, successors[i])
 			}
 		}