Wishing Well (not going well) (Python)[SOLVED]

i keep getting an infinite loop (or my code is running really slow) error.

i think its where i’m calling my function but i cant figure out exactly what ive done wrong.

here it is:

# You need exactly 104 gold. 

less = "Nimis"
more = "Non satis"
requiredGold = 104

# This function calculates the sum of all coin values.
def sumCoinValues(coins):
    coinIndex = 0
    totalValue = 0
    # Iterate all coins.
    while coinIndex < len(coins):
        totalValue += coins[coinIndex].value
        coinIndex += 1
    return totalValue

def collectAllCoins():
    item = hero.findNearest(hero.findItems())
    while item:
        hero.moveXY(item.pos.x, item.pos.y)
        item = hero.findNearest(hero.findItems())

while True:
    items = hero.findItems()
    # Get the total value of coins.
    goldAmount = sumCoinValues(items)
    # If there are coins, then goldAmount isn't zero.
    if goldAmount != 0:
        # If goldAmount is less than requiredGold
        if goldAmount < requiredGold:
            # Then say "Non satis".
            hero.say(less)
        # If goldAmount is greater than requiredGold
        if goldAmount > requiredGold:
            # Then say "Nimis".
            hero.say(more)
        # If goldAmount is exactly equal to requiredGold
        if goldAmount == requiredGold:
            # Then collect all coins:
            collectAllCoins() 
        

Hi Psyko2k,

Change the hero.say(more) to hero.say(“Nimis”), and the hero.say(less) to hero.say(“Non satis”).

What you have should work (and indeed appears to work), but I think there’s maybe a bug in the programme.

Jenny

1 Like

Yes, the default code is wrong. Change at the start of the program

# less = "Nimis"
# more = "Non satis"
# to
less = "Non satis"
more = "Nimis"

At least this is the correct Latin…

2 Likes

Hey,

sorry i took so long to reply. Its been hectic here.

That worked straight way! Thanks for response :smiley:

one question though. why did that work?
if more = "Nimis" then surely by coding in hero.say(more) then that should’ve worked?
otherwise what is the point of creating that function (if thats what its called)?

again thanks for the help :slight_smile:

I hadn’t realised it until @xython said, but the variables are the wrong way round, so the hero is saying the wrong word. If you put in

        if goldAmount < requiredGold:
            # Then say "Non satis".
            hero.say(more)
        # If goldAmount is greater than requiredGold
        if goldAmount > requiredGold:
            # Then say "Nimis".
            hero.say(less)

then it works.

There is a way to suggest corrections to CoCo via Github, but I got a bit lost when I tried it before :grinning:.

Hmm, I’m confused.
I reloaded this level to try it again and it worked perfectly.

At the top of the level it says:
less = “Nimis”
more = “Non satis”
That seems to fit up to me.
It tells you to say “Non satis”, and you can use hero.say(more). It says at the top that Non satis = more, so that would make sense.
You may already know this, but nimis means less in latin, and no satis is “not satisfied”. e.g. more.
Maybe I’m missing the point, but I used:

if goldAmount < requiredGold:
    # Then say "Non satis".
    hero.say(more)
# If goldAmount is greater than requiredGold
if goldAmount > requiredGold:
    # Then say "Nimis".
    hero.say(less)

With:

less = "Nimis"
more = "Non satis"

(The default code)
And it worked fine.

Ha - maybe we both just got mixed up with which way round the phrases went then :laughing:. Ho hum.

Thanks for the latin - we didn’t do that at my school…

:grin:

J.

1 Like

deadpool: " but nimis means less in latin" , - No
image
image
image
“satis is “not satisfied”. e.g. more” - No - not satisfied means less
image

For all readers of the topic:

“The lyrics to this were truly threatening to an older audience. This song was perceived as an attack on the status quo.”
Don’t be afraid to question the correctness of the default code and all the authorities in general :slight_smile:

1 Like

I accept that a level could be wrong, but I’m sure about the meaning of the Latin. My Latin dictionary (like google) says that nimis means too much. If I was given a massive slice of cake and I wanted less, I would say “too much”. You say the amount is “too much”, meaning you want less. I could have just said “less” (if I was rude), and received the same result: less cake.
Same with non satis. Satis means “enough”, “sufficient”. So non satis is “not sufficient”, meaning more. There isn’t sufficient stone to build this castle, meaning I need some more. Result: I get more stone.
I have no problem accepting levels can be wrong (For example I think this level has a bug, and I submitted a patch: Cursed Valley- didn't lose health? - #13 by Deadpool198), but I’ve been doing Latin since I was 7 (my granny taught me :grin: (up until about 5 months ago…)), and I’m sure about the meaning of the words.
Danny

1 Like

I don’t want to argue. We both take the same fact and we have different actions.
For me it’s a statement for of the fact that the amount is too much, not asking for less, and the initial phrases must be the correct translation to English.

This topic was automatically closed 12 hours after the last reply. New replies are no longer allowed.