# Sarven Sum Fire trap calculation help

I cannot do the level sarven sum with arithmetic for the traps.
code
‘’’
whiteX = {‘x’:27, ‘y’:42}
redX = {‘x’:151 , ‘y’: 118}

minHazard = None
min = 9999
maxHazard = None
max = 0
index = 0
hazards = hero.findHazards()
while len(hazards) > index:
if hazards[index].value < min:
minHazard = hazards[index]
min = hazards[index].value
if hazards[index].value > max:
maxHazard = hazards[index]
max = hazards[index].value
index += 1
nn = min + max
hero.moveXY(27, 42)
hero.say(nn)
while True:
flag = hero.findFlag(“green”)
if flag:
hero.pickUpFlag(flag)
‘’’

1 Like

I used triple batsticks but it does not format and my hero says the wrong sum

1 Like

I see. Those aren’t backticks. Those are single quotes.
Or you can click on the `</>` symbol. 1 Like

ok thanks hellenar (must be 20 chars)

1 Like
``````whiteX = {'x':27, 'y':42}
redX = {'x':151 , 'y': 118}

minHazard = None
min = 9999
maxHazard = None
max = 0
index = 0
hazards = hero.findHazards()
while len(hazards) > index:
if hazards[index].value < min:
minHazard = hazards[index]
min = hazards[index].value
if hazards[index].value > max:
maxHazard = hazards[index]
max = hazards[index].value
index += 1
nn = min + max
hero.moveXY(27, 42)
hero.say(nn)
while True:
flag = hero.findFlag("green")
if flag:
hero.pickUpFlag(flag)
``````
1 Like

2 Likes

O sorry.
here

``````# To disable the fire-traps add the lowest trap.value to the highest value.
# Move to the white X and say the answer to Kitty the cougar.
# Defeat all the ogres if you dare.
# Once all ogres are defeated move to the red X.
# Look out for potions to boost your health.

# To disable the fire-traps add the lowest trap.value to the highest value.
# Move to the white X and say the answer to Kitty the cougar.
# Defeat all the ogres if you dare.
# Once all ogres are defeated move to the red X.
# Look out for potions to boost your health.

whiteX = {'x':27, 'y':42}
redX = {'x':151 , 'y': 118}

minHazard = None
min = 9999
maxHazard = None
max = 0
index = 0
hazards = hero.findHazards()
while len(hazards) > index:
if hazards[index].value < min:
minHazard = hazards[index]
min = hazards[index].value
if hazards[index].value > max:
maxHazard = hazards[index]
max = hazards[index].value
index += 1
nn = min + max
hero.moveXY(27, 42)
hero.say(nn)
while True:
flag = hero.findFlag("green")
if flag:
hero.pickUpFlag(flag)

``````
1 Like

It says value is undefined

1 Like

Try defining `hazard = hazards[index]` first.

3 Likes essaye ceci

Thanks for posting and trying to help, but please don’t post on very old topics. These people aren’t active anymore and have very likely finished this level.
Thanks
Danny

1 Like

Ok je serai pour la prochaine fois. J ai vu que ça faisait longtemps mais c’est surtout pour les autres personne qui verai ce topic. Au moins on peut le mettre en “résolu”.  1 Like