Deja Brew - sing all lines but still failing

I’ve said all the same lines as the conductor. on the fifth potion it stops and says failing even though he says the exact same thing as the conductor again.
My Code:
var potionsOnTheWall = 10;
var numToTakeDown = 1;
while(true) {
hero.say(potionsOnTheWall + " potions of health on the wall!");
// Sing the next line:
hero.say(potionsOnTheWall + " potions of health!");
// Sing the next line:
hero.say(“take 1 down and pass it around”);
potionsOnTheWall -= numToTakeDown;
// Sing the last line:
hero.say(potionsOnTheWall + " potions of health on the wall!");
}

1 Like

Nm

answer:

(solution removed)

1 Like

Glad, you found your answer, it may help to put your code in the ‘code’ format when posting to the forums, that way others can read your code better. It is the symbol on the toolbar for posting that looks like this: < / >

2 Likes

Can you help me find the answer? I just cant find it. Here is my current code.
potionsOnTheWall = 10
numToTakeDown = 1
while True:
self.say(potionsOnTheWall + " potions of health on the wall!")
self.say(potionsOnTheWall + " potions of health!")
self.say(“take” + numToTakeDown + " pass it around!")
potionsOnTheWall -= numToTakeDown
self.say(potionsOnTheWall + " potions of health on the wall!")

1 Like

Missing " down, …".

hero.say("Take " + numToTakeDown + " down, pass it around!")

Else it would be “Take n pass it around” instead of “Take n down, pass it around”.

Also, be sure to leave spaces in between quotes and variables so it doesn’t end up like “Takendown, pass it around”.

1 Like

Thanks, I tried it and it worked.

1 Like

I have the same problem as OP but in Python, and also, hero keeps singing “NaN potions of health”

potionsOnTheWall = 10
numToTakeDown = 1
while True:
    hero.say(potionsOnTheWall + " potions of health on the wall!")
    # Singe die nächste Strophe:
    hero.say(potionsOnTheWall + " potions of health!")
    # Singe die nächste Strophe:
    hero.say("take one down, pass it around" + potionsOnTheWall-1 + " potions of health on the wall!")
    potionsOnTheWall -= numToTakeDown

I also don’t understand why there’s a level requirement to sing the last verse separately - it should get there automatically with this bit of code - if it works as intended.

1 Like

No, it shouldn’t work the way you’ve written it. The proper way would be to increment the potionsOnTheWall variable before the last say statement and then call the updated variable. Instead, you’ve incremented inside the say method and then increment after that line.

2 Likes

The first 7 lines of code are right, it’s the rest which are wrong, maybe on the 8th line say "take" + numToTakeDown + "down, pass it around" and stop there for the rest of the line.
In the 9th line you say potionsOnTheWall -= numToTakeDown
Then you say potionsOnTheWall + "potions of health on the wall!"
Hope this helps. :grin:

1 Like

Why use numToTakeDown at all in this level? We always wanna take down exactly one, right?

I posted 7 lines of code above, you said they were right. Then, your suggestion:

"take" + numToTakeDown + "down, pass it around"
    potionsOnTheWall -= numToTakeDown
    hero.say(potionsOnTheWall + " potions of health on the wall!")

doesn’t work! :confused:

1 Like

yeah my mistake you can just say: take one down pass it around. :sweat_smile:
but apart from that it should/does work.

1 Like

I used the variable numToTakeDown in that say statement in my original code and it worked fine.

1 Like

I’ll PM you my code and a screenshot if you want, I’ve already done the level, I’ve got it in front of me.

1 Like

In that case, the pre-written code (or comments) are misleading: The incrementation (or what do you call it) potionsOnTheWall -= numToTakeDown is clearly placed to be written after the second (or third) say statement, as you can see:

I used this now:

potionsOnTheWall = 10
numToTakeDown = 1
while True:
    hero.say(potionsOnTheWall + " potions of health on the wall!")
    hero.say(potionsOnTheWall + " potions of health!")
    # Singe die nächste Strophe:
    potionsOnTheWall -= numToTakeDown
    hero.say(" take one down, pass it around " + potionsOnTheWall + " potions of health on the wall!")

It behaves as expected, but doesn’t beat the level.

1 Like

potionsOnTheWall = 10
numToTakeDown = 1
while True:
hero.say(potionsOnTheWall + " potions of health on the wall!")
# Sing the next line:
hero.say(potionsOnTheWall + " potions of health!")
# Sing the next line:
hero.say(“Take " + numToTakeDown + " down, pass it around!”)
potionsOnTheWall -= numToTakeDown
# Sing the last line:
hero.say(potionsOnTheWall + " potion of health on the wall!")

I code it! And still failing :)) why? Please help me!!!

1 Like

please format your code properly using the button and putting you code in the paste or type your code here.

1 Like

The variable works, but I don’t understand what it’s for, because its value doesn’t vary. :smile:

Yes, if you could please, that would be great

1 Like

No, it places the increment exactly where it should be. Your original code posted above places it after the third say statement, not where it should be.

1 Like

Unanswered questions:

  1. Why that extra instruction to “sing the last verse”?
  2. Why the need for a numToTakeDown variable?
  3. What are the exact requirements for beating the level, i.e. what is the exact text that should be produced in order to count as a valid sing-along?

In the screenshot above, there are three yellow arrows, each pointing to one comment with instructions what to do (“sing the xth verse”). Under each of these comments, there’s one line of emtpy space.
This combination of arrows, instructions and empty spaces leads me to believe that I’m supposed to write my say statements where the empty spaces are.
Would you say this is a stupid way of seeing it?
Anyways, if I follow this logic and do put one say statement in each of these empty lines, then that places potionsOnTheWall -= numToTakeDown after the 3rd say statement.
That’s what I meant be this being misleading.

1 Like

potionsOnTheWall = 10
numToTakeDown = 1

while True:
      hero.say(potionsOnTheWall + " potions of health on the wall!")
      hero.say(potionsOnTheWall + " potions of health!")
      hero.say("Take " + numToTakeDown + " down, pass it around!")
      potionsOnTheWall -= numToTakeDown
      hero.say(potionsOnTheWall + " potion of health on the wall.")

Yeah, I code like this! but error! Code can run and stop at 5 potion :frowning:

1 Like