This commit is contained in:
Karl Spickermann 2022-12-20 02:29:54 +01:00
parent 68f008c7ff
commit 6feb1f428a

View File

@ -23,8 +23,8 @@ type Blueprint struct {
func main() { func main() {
//args := os.Args[1:] //args := os.Args[1:]
lines := helper.ReadTextFile("day19/input") lines := helper.ReadTextFile("day19/input")
highestGeode := make([]int, len(lines)) highestGeode := make([]int, len(lines[:3]))
for i, line := range lines { for i, line := range lines[:3] {
blueprint := getBluePrint(line) blueprint := getBluePrint(line)
highestGeodeLine := 0 highestGeodeLine := 0
for j := 0; j < 50; j++ { for j := 0; j < 50; j++ {
@ -36,9 +36,9 @@ func main() {
highestGeode[i] = highestGeodeLine highestGeode[i] = highestGeodeLine
fmt.Println(highestGeode[i]) fmt.Println(highestGeode[i])
} }
sum := 0 sum := 1
for i, score := range highestGeode { for _, score := range highestGeode {
sum += (i + 1) * score sum *= score
} }
fmt.Println(highestGeode) fmt.Println(highestGeode)
fmt.Println(sum) fmt.Println(sum)
@ -98,13 +98,13 @@ func step(activeStates *map[[4]int]State, fastestTImeToObsidian *State, untilEle
func stepHighestGeode(activeStates *map[[4]int]State, endStates *[]State, blueprint *Blueprint) { func stepHighestGeode(activeStates *map[[4]int]State, endStates *[]State, blueprint *Blueprint) {
newTmpStates := generatePossibleTmpStates(activeStates, blueprint) newTmpStates := generatePossibleTmpStates(activeStates, blueprint)
for _, tmpState := range newTmpStates { for _, tmpState := range newTmpStates {
if tmpState.runtime < 24 && !checkOptimal(tmpState, blueprint) { if tmpState.runtime < 32 && !checkOptimal(tmpState, blueprint) {
identifier := getIdentifier(tmpState) identifier := getIdentifier(tmpState)
elem, ok := (*activeStates)[identifier] elem, ok := (*activeStates)[identifier]
if !ok || elem.runtime > tmpState.runtime || (elem.runtime == tmpState.runtime && checkBetterRessources(tmpState, elem)) { if !ok || elem.runtime > tmpState.runtime || (elem.runtime == tmpState.runtime && checkBetterRessources(tmpState, elem)) {
(*activeStates)[identifier] = tmpState (*activeStates)[identifier] = tmpState
} }
} else if tmpState.runtime > 24 { } else if tmpState.runtime > 32 {
fmt.Println("WTF") fmt.Println("WTF")
} else { } else {
*endStates = append(*endStates, tmpState) *endStates = append(*endStates, tmpState)