day21 - me being stupid ...
This commit is contained in:
parent
b8e78e8472
commit
3bcae36e43
19
day21/day.go
19
day21/day.go
@ -123,25 +123,26 @@ func Part1(puzzle tools.AoCPuzzle) interface{} {
|
|||||||
goldSpent := 0
|
goldSpent := 0
|
||||||
|
|
||||||
minGold := math.MaxInt32
|
minGold := math.MaxInt32
|
||||||
// completely ignoring rings for p1 as they are way too expensive in any case
|
|
||||||
for _, weaponStats := range weapons {
|
for _, weaponStats := range weapons {
|
||||||
for _, armorStats := range armor {
|
for _, armorStats := range armor {
|
||||||
goldSpent = weaponStats["cost"] + armorStats["cost"]
|
goldSpent = weaponStats["cost"] + armorStats["cost"]
|
||||||
playerPower = weaponStats["damage"]
|
for ring1Name, ring1Stats := range rings {
|
||||||
playerArmor = armorStats["armor"]
|
for ring2Name, ring2Stats := range rings {
|
||||||
|
if ring1Name == ring2Name {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
goldSpent = weaponStats["cost"] + armorStats["cost"] + ring1Stats["cost"] + ring2Stats["cost"]
|
||||||
|
playerPower = weaponStats["damage"] + ring1Stats["damage"] + ring2Stats["damage"]
|
||||||
|
playerArmor = armorStats["armor"] + ring1Stats["armor"] + ring2Stats["armor"]
|
||||||
|
|
||||||
if fight(playerHp, playerPower, playerArmor, bossHp, bossPower, bossArmor) && goldSpent < minGold {
|
if fight(playerHp, playerPower, playerArmor, bossHp, bossPower, bossArmor) && goldSpent < minGold {
|
||||||
minGold = goldSpent
|
minGold = goldSpent
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// REVISIT: The "correct" answer according to AoC website was 78, but that doesn't work!
|
|
||||||
// The only way to spent 78 Gold is by buying a Warhammer and the Splintmail
|
|
||||||
// That put the player damage at 6(weapon)-1(bossArmor) == 5
|
|
||||||
// And the boss damage becomes 8(input)-3(armor) == 5
|
|
||||||
// But the boss has 104 HP and the player only 100.
|
|
||||||
// Leaving the player dead after 20 Rounds with the boss still having 4 HP
|
|
||||||
return minGold
|
return minGold
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user