Browse Source

Solved for sample

Piotr Czajkowski 1 year ago
parent
commit
3aed473b4d
1 changed files with 1 additions and 8 deletions
  1. 1 8
      17/code.go

+ 1 - 8
17/code.go

@@ -5,7 +5,6 @@ import (
 	"fmt"
 	"log"
 	"os"
-	"sort"
 )
 
 const (
@@ -233,20 +232,14 @@ func part1(board [][]int) int {
 		}
 
 		successors := getDestinations(board, height, width, current)
-		fmt.Println(current, successors)
 		for i := range successors {
-			newCost := successors[i].cost + successors[i].moves
+			newCost := successors[i].cost
 			value, ok := explored[successors[i].pos]
 			if !ok || value > newCost {
 				explored[successors[i].pos] = newCost
 				frontier = append(frontier, successors[i])
 			}
 		}
-
-		sort.Slice(frontier, func(i, j int) bool {
-			return frontier[i].cost+frontier[i].moves < frontier[j].cost+frontier[j].moves
-		})
-
 	}
 
 	return min