Day12 Fix

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

View File

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