Day12 Fix

This commit is contained in:
Karl Spickermann 2022-12-13 00:01:35 +01:00
parent 6401908349
commit 354ea4878b

@ -3,6 +3,7 @@ package main
import (
"AOC2022/helper"
"fmt"
"os"
)
type FieldPoint struct {
@ -12,15 +13,14 @@ type FieldPoint struct {
}
func main() {
//args := os.Args[1:]
lines := helper.ReadTextFile("day12/inputFichte")
args := os.Args[1:]
lines := helper.ReadTextFile(args[0])
start, end := getStartingPointAndEndpoint(lines)
fmt.Println(start)
fmt.Println(end)
field := getField(lines)
part1(field, end)
print(field)
//fastestPath := part2(lines, field, end)
part1(field, start, end)
part2(lines, field, end)
}
@ -39,10 +39,10 @@ func part2(lines []string, field [][]FieldPoint, end [2]int) {
fmt.Println(fastestPath)
}
func part1(field [][]FieldPoint, end [2]int) {
func part1(field [][]FieldPoint, start, end [2]int) {
activePoints := make(map[[2]int]struct{})
activePoints[[2]int{0, 0}] = struct{}{}
fmt.Println(getBestRouteLength(activePoints, field, end) + 2)
activePoints[start] = struct{}{}
fmt.Println(getBestRouteLength(activePoints, field, end))
}
func getField(lines []string) [][]FieldPoint {