Ice Hunter Help - Cloudrip Mountain(python)

This is my code:

#Hunt for 4 yaks. Choose only the small ones.
#Small yak names contain a "bos" substring.

#This function checks if a word contains a substring.
def isSubstring(word, substring):
    # We iterate through the start indexes only.
    rightEdge = len(word) - len(substring)
      #Loop through the indexes of the word.
    for i in range(rightEdge + 1):
        #For each of them loop through the substring
        for j in range(len(substring)):
            #Use an offset for the word's indexes.
            shiftedIndex = i + j
            #If letters aren't the same:
            if word[shiftedIndex] != substring[j]:
                # Check the next start index in the word.
                break
            #If it was the last letter in the substring:
            if j == len(substring) - 1:
                #Then the substring is in the word.
                return True
    #We haven't found the substring in the word.
    return False

#Loop through all enemies.
enemies = hero.findEnemies()
for e  in range(len(enemies)):
    enemy = enemies[e]
    # Use the function isSubstring to check
    # if an enemy.id contains "bos":
    if isSubstring(enemy.id, 'bos'):
        # Then defeat it.
        while enemy.health>0:
            hero.attack(enemy)

My Hero just kill 3 yaks, not 4. Is it my code, or a bug??? PLEASE HELP! :pensive:

@Luk212

1 Like

Hero: Hattori
Health: 740 :heart:
Sword: Runesword
And Boss Star II

Hum… I don’t know how to upload my inventory image :sweat_smile:

1 Like

Your code is absolutely right, I think really small amount of health is the problem. Try to use Tharin, or any of the starter heroes (if you don’t have warriors like Gordon or Okar) because they have more health.

2 Likes

Hi, @Luk212 ,welcome to the codecombat discourse! :partying_face:
Yeah as peter said, your code is right, you just need good armors

And if you don’t have enoght gems, you can go to any ladders, and pess the button “simulate”
Then just go and do other things, like: go read books!
And soon, you will gets gems! :smiley:

Don’t use hattori, his health is too low

Ok, Thank You @PeterPalov and @Jason_king_lin !!!

1 Like

Oh oh, I tried with Okar and other heroes. But it doesn’t work! :worried:
Is it a bug, maybe (or something like that)?

The website : CodeCombat - Coding games to learn Python and JavaScript

1 Like

Could you show a screenshot of the level?

1 Like

Search for the shortcut for your computer

1 Like


I watched a video of how to do a screenshot.

1 Like

To check whether a substring is in a string you can just use the Python in-built in method :upside_down_face:
way to use:

substring in string
# or
substring not in string
1 Like

I…don’t understand, I don’t speak english 100%

1 Like

Its ok. To moonwatcher: you can use both ways and its not the problem

1 Like

I do realize that, but I like using the most efficient way possible :)

1 Like

I watched a video on YT and done the same thing, but…

1 Like

what language do you main? (chinese, indian etc)

1 Like

your code should be working, try submitting lots of times, they have different seeds every time :slight_smile:

2 Likes

@Luk212 it is ok!
I don’t know how to speak good english too!
But i finished all levels on Codecombat!

Ok, @Jason_king_lin and @riticmaster908

1 Like