[Adventurer] Three-step Password

The Mountain level Three-step Password is ready for playtesting!

The second level in the series of levels about str.split(sep) method.

1 Like

@Bryukh it looks like in the Python code on line 16 index = friend.index; there is a semi-colon? (removed in the patch)

completed the level without issue.

Added LUA patch

Thanks. Usually, I write JS code and then convert it to PY. So those artifacts (:wink: are possible :slight_smile:

what am I not following here. Is the index they get supposed to tell me what index to call in the array? Am I storing them in the array wrong?

# Find the password for the gates and defeat the ogres.

# Get the secret message.
hero.moveXY(52, 50)
friend = hero.findNearest(hero.findFriends())
message = friend.message

# Get the separator symbol.
hero.moveXY(66, 34)
friend = hero.findNearest(hero.findFriends())
separator = friend.separator

# Get the index.
hero.moveXY(52, 18)
friend = hero.findNearest(hero.findFriends())
index = friend.index

# Move to the gates.
hero.moveXY(44, 34)
# Split the message with the separator to get an array:
wordsArray = message;separator;index

words = wordsArray.split(";")
# Get the password from the array of words by the index:
password = words[0]
# Say the password:
hero.say(password)

# Defeat the ogres:
while True:
    enemy = hero.findNearestEnemy()
    if enemy:
        hero.attack(enemy)

What are you trying to do here?

trying to put the messages into the array, if I put quotes it just puts the string in. Am I supposed to be using append or something? I thought the point was to use the split method somehow. Maybe I am confused.

Have you played levels before that? About arrays, strings? Also there is one more with demonstration of split usage.

message;separator;index – it’s something weird.
You have a message - split it and you’ll get words.

alright, so I feel dumb, that was pretty obvious instructions. use the separator as the separator…sorry for dumb question.

I can’t figure out what is wrong. Here is my code:

# Find the password for the gates and defeat the ogres.

# Get the secret message.
hero.moveXY(52, 50)
friend = hero.findNearest(hero.findFriends())
message = friend.message

# Get the separator symbol.
hero.moveXY(66, 34)
friend = hero.findNearest(hero.findFriends())
separator = friend.separator

# Get the index.
hero.moveXY(52, 18)
friend = hero.findNearest(hero.findFriends())
index = friend.index

# Move to the gates.
hero.moveXY(44, 34)
# Split the message with the separator to get an array:
words = message.split("separator")
# Get the password from the array of words by the index:
password = words[index]
# Say the password:
hero.say(password)

# Defeat the ogres:
while True:
    enemy = hero.findNearestEnemy()
    if enemy:
        hero.attack(enemy)

At line 25 it tells me that say’s argument message should have type string, but got null.

Never mind…all I had to do was remove the quotes from line 21, then I beat the level. Sorry for disturbing anyone.

You wrapped seperator in double quotes

1 Like

Yeah, I mentioned that…

Hey you think you guys could help me with this website im new to it?

What exactly is it that you need help with? It’s a board where people help each other with their code. Feel free to poke around and see how it works.

thanks dude!!!

1 Like

Make sure to format your code properly using the format code button, and to never post final solutions on this forum. If you need any help, i will be there to guide you. You can always contact me at my email:
777brandonreyes@gmail.com