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.
#If it was the last letter in the substring:
if j == len(substring) - 1:
#Then the substring is in the word.
#We haven't found the substring in the word.
#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.
My Hero just kill 3 yaks, not 4. Is it my code, or a bug??? PLEASE HELP!
And Boss Star II
Hum… I don’t know how to upload my inventory image
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.
Hi, @Luk212 ,welcome to the codecombat discourse!
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!
Don’t use hattori, his health is too low
Oh oh, I tried with Okar and other heroes. But it doesn’t work!
Is it a bug, maybe (or something like that)?
Could you show a screenshot of the level?
Search for the shortcut for your computer
I watched a video of how to do a screenshot.
To check whether a substring is in a string you can just use the Python in-built
way to use:
substring in string
substring not in string
I…don’t understand, I don’t speak english 100%
Its ok. To moonwatcher: you can use both ways and its not the problem
I do realize that, but I like using the most efficient way possible :)
I watched a video on YT and done the same thing, but…
what language do you main? (chinese, indian etc)
your code should be working, try submitting lots of times, they have different seeds every time
@Luk212 it is ok!
I don’t know how to speak good english too!
But i finished all levels on Codecombat!