[SOLVED] Help in Yeti Away and Medic School levels

Hello all! I’ve been stuck on the levels above. Here’s my code for Yeti Away:

# Follow one of the peasants and escape from the yeti.
hero.phaseShift()
def startsWith(phrase, word):
    if len(word) > len(phrase):
        return False
    # Iterate indexes from 0 to the length of the word.
    for i in range(len(0, len(word))):
        # Check the letter of phrase and word at index i
        word = word[i]
        phrase = phrase[i]
        # If they are not equal:
        if word != phrase:
            # Then return False.
            return False
    # All letters in the word checked, then return true.
    return True

# Follow the local guide whose name starts with "Mac".
guides = hero.findFriends()
for gIndex in range(len(guides)):
    guide = guides[gIndex]
    if startsWith(guide.id, "Mac"):
        while True:
            hero.move(guide.pos)

It worked the first time but on the second(third and so on) submit, my hero keeps following the top peasant
link(Yeti Away). As for the Medic School level, being very similar to Yeti way, should be easy to solve after solving the Yeti level. All help is appreciated :smile:

startsWith does not make sense
what if the phrase is Macdaddy
not equal, but starts with Mac

You need to make something that will make an array for each character in phrase
then you can check the first three terms and see if they are M, A, and C.

It came with the default code so :person_shrugging:.

So something like

a = phrase
m = phrase
b = phrase

apples = A
Michael = apples
macros = M
hero = macros
bananas = B
fruits = bananas

?

I see only 2 tiny problems,

This is too complicated, no need for the len where it has the zero and another length
Hint: range(len(word))

Give the variables different names, so w = word[i] for example, same for phrase

It worked! Thx @Aya, (Yea and it also worked for Medic school)

hint(to whoever is stuck on this level(Medic school))

It’s literally the same code just with extra movement to the potions

1 Like

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