Play Home Contribute Github Join Us! Discourse Staff Members Github Contribution Guides Team

[SOLVED] Help with count emptiness please

hi. i think that i only need help with the line below the commented out one. here’s my code:

def moveNSteps(n):
    hero.move({"x":hero.pos.x + (8 * n), "y":hero.pos.y})
riddle = hero.findNearestEnemy().riddle
trimmed = riddle.trim()
# Find the difference between the `riddle` and `trimmed` lengths:
n = trimmed
moveNSteps(n)
hero.say("come out")

hi @AnSeDra, could you help me please?

Here put

n = len(riddle) - len(trimmed)

Do you need any more assistance at this level?

yes, it says that i need an x : number, y : number position for the move argument. why?

Can you show me your code?

here:

def moveNSteps(n):
    hero.move({"x":hero.pos.x + (8 * n), "y":hero.pos.y})
riddle = hero.findNearestEnemy().riddle
trimmed = riddle.trim()
# Find the difference between the `riddle` and `trimmed` lengths:
n = riddle - trimmed
moveNSteps(n)
hero.say("come out")

I updated this so it is

Does it work now?

no he dies instantly :rofl:

here’s the code:

def moveNSteps(n):
    hero.move({"x":hero.pos.x + (8 * n), "y":hero.pos.y})
riddle = hero.findNearestEnemy().riddle
trimmed = riddle.trim()
n = len(riddle) - len(trimmed)
moveNSteps(n)
hero.say("come out")

Can you send me the link to the level?

he actually doesn’t move and says come out. and then dies

ok, but i need to go for about 30 minutes here’s the link:
https://codecombat.com/play/level/count-emptiness?

Try to put moveXY instead of move from here

So put

hero.moveXY(hero.pos.x + 8*n, hero.pos.y)

Does it work now?

i did but this happened:


i really need to go now though. see you in 30 minutes

Try to put this

In the function and delete the “x” and the “y”.
Do you need any more assistance at this level?

hi again. i’m back and here’s the new code:

def moveNSteps(n):
    num = hero.pos + 8 * n
    hero.moveXY(num, hero.pos)
riddle = hero.findNearestEnemy().riddle
trimmed = riddle.trim()
i = len(riddle) - len(trimmed)
moveNSteps(i)
hero.say("come out")

it says that i have a string instead of numbers on the moveXY() line

1 Like

but i fixed it @AnSeDra, and i beat the level. yay :partying_face:

2 Likes

Congratulations for completing the level! :partying_face: