Day19
This commit is contained in:
parent
68f008c7ff
commit
6feb1f428a
@ -23,8 +23,8 @@ type Blueprint struct {
|
||||
func main() {
|
||||
//args := os.Args[1:]
|
||||
lines := helper.ReadTextFile("day19/input")
|
||||
highestGeode := make([]int, len(lines))
|
||||
for i, line := range lines {
|
||||
highestGeode := make([]int, len(lines[:3]))
|
||||
for i, line := range lines[:3] {
|
||||
blueprint := getBluePrint(line)
|
||||
highestGeodeLine := 0
|
||||
for j := 0; j < 50; j++ {
|
||||
@ -36,9 +36,9 @@ func main() {
|
||||
highestGeode[i] = highestGeodeLine
|
||||
fmt.Println(highestGeode[i])
|
||||
}
|
||||
sum := 0
|
||||
for i, score := range highestGeode {
|
||||
sum += (i + 1) * score
|
||||
sum := 1
|
||||
for _, score := range highestGeode {
|
||||
sum *= score
|
||||
}
|
||||
fmt.Println(highestGeode)
|
||||
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) {
|
||||
newTmpStates := generatePossibleTmpStates(activeStates, blueprint)
|
||||
for _, tmpState := range newTmpStates {
|
||||
if tmpState.runtime < 24 && !checkOptimal(tmpState, blueprint) {
|
||||
if tmpState.runtime < 32 && !checkOptimal(tmpState, blueprint) {
|
||||
identifier := getIdentifier(tmpState)
|
||||
elem, ok := (*activeStates)[identifier]
|
||||
if !ok || elem.runtime > tmpState.runtime || (elem.runtime == tmpState.runtime && checkBetterRessources(tmpState, elem)) {
|
||||
(*activeStates)[identifier] = tmpState
|
||||
}
|
||||
} else if tmpState.runtime > 24 {
|
||||
} else if tmpState.runtime > 32 {
|
||||
fmt.Println("WTF")
|
||||
} else {
|
||||
*endStates = append(*endStates, tmpState)
|
||||
|
Loading…
Reference in New Issue
Block a user