[SOLVED] Stuck on Wizards plane using python coding

Move to Eszter and get the secret number from her.

hero.moveXY(16, 32)
esz = hero.findNearestFriend().getSecret()

Multiply by 3 and subtract 2 to get Tamas’s number.

Remember to use parentheses to do calculations in the right order.

Move to Tamas and say his magic number.

tam = (esz * 3) - 2
hero.moveXY(24, 28)
hero.say(esz * 3 - 2 )

Subtract 1 and multiply by 4 to get Zsofi’s number.

Move to Zsofi and say her magic number.

hero.moveXY(32, 24)
hero.say((tam - 1) * 4)

Add Tamas’s and Zsofi’s numbers, then divide by 2 to get Istvan’s number.

Move to Istvan and say his magic number.

hero.moveXY(40, 20)
hero.say((((tam - 1) * 4) + tam) / 2)

Add Tamas’s and Zsofi’s numbers, subtract Istvan’s number from Zsofi’s, and multiply the results to get Csilla’s number.

Move to Csilla and say her magic number.

hero.moveXY(48, 16)
hero.say((((((((((tam) + tam - 1) * 4) * tam) - 1) * 4) + tam - 1) * 4) + tam) / 2)

been staring at this for 3 hours and tried everything i can think of please help me
Everything works except the last string for finding Csilla’s number

Try to use variables to save results between. It’ll make your code readable and simpler.

If you save all results then the last will be
(tamas + zsofi) * (zsofi - istvan)

what do you mean by save results? I may have misread something

Look. You’ve saved Tamas’s number into the variable

tam = (esz * 3) - 2

But for Zsofi you don’t do it

hero.say((tam - 1) * 4)

So if you had saved it in a variable you would have used it as

hero.say((zsofi + tam) / 2) // instead (((tam - 1) * 4) + tam) / 2)

And the last calculation can be more readable that way.

I finally did it thank you i think i missed the saving part the final code i used is shown below

[redacted, please don’t post solutions]

thanx really helped

> [en_US.composer.my_button_text]

type or paste code here
```# Move to 'Eszter' and get the secret number from her.
hero.moveXY(16, 32)
esz = hero.findNearestFriend().getSecret()

# Multiply by 3 and subtract 2 to get 'Tamas's number.
# Remember to use parentheses to do calculations in the right order.
# Move to 'Tamas' and say his magic number.
tam = (esz * 3) - 2
hero.moveXY(24, 28)
hero.say(tam)

# Subtract 1 and multiply by 4 to get 'Zsofi's number.
# Move to 'Zsofi' and say her magic number.
zso = tam - (1 * 4)
hero.moveXY(32, 24)
hero.say("84")
# Add 'Tamas's and 'Zsofi's numbers, then divide by 2 to get 'Istvan's number.
# Move to 'Istvan' and say his magic number.
ist = (tam + zso) / 2
hero.moveXY(40, 20)
hero.say("53")
# Add 'Tamas's and 'Zsofi's numbers. Subtract 'Istvan's number from 'Zsofi's. Multiply the two results to get 'Csilla's number.
# Move to 'Csilla' and say her magic number.
csi = ("tamas" + "zsofi") * ("zsofi" - "istvan")
hero.moveXY(48, 16)
hero.say("3,286")

Hi @Piemaker_Pri, welcome to the CodeCombat discourse :tada:
You’re hardcoding magic numbers when you should be using the variables you made. It might work sometimes, but most of the time it won’t.
Danny

I did, but my hero died when I went to Zsofi. What else should I do?

That’s because this is wrong.

# Subtract 1 and multiply by 4 to get 'Zsofi's number.

Subtract 1 then multiply by 4. Not tam - (1*4)
Danny

Oh sorry I just solved it. Thanks though.