It’s adding NaN (not a number) to the number.
The way I proved that was by temporarily using “say”.
What should I do?
- Try to continue this level (specify a hint on what to do)
- Skip this level and continue after finishing the next level
- Take some code from GitHub (not recommended)
0
voters
Here’s my code, BTW.
# You must collect the required amount of gold.
# The gate keeper will tell you how much you need.
# Always move in the direction of the exit.
# For each row you can take only one coin.
# Choose only one from the nearest coins in the next row.
# Distance between rows and coins.
distanceX = 4
distanceY = 6
zeroPoint = {"x": 14, "y": 14}
coinLines = 10
def makeGoldMap(coins):
template = [[0 for j in range(2 * coinLines - 1)] for i in range(coinLines)]
for coin in coins:
row = int((coin.pos.y - zeroPoint.y) / distanceY)
col = int((coin.pos.x - zeroPoint.x) / distanceX)
template[row][col] = coin.value
return template
# Prepare the gold map. It looks like:
# [[1, 0, 9, 0, 4],
# [0, 1, 0, 9, 0],
# [8, 0, 2, 0, 9]]
goldMap = makeGoldMap(hero.findItems())
# Find your path.
#detect which path is correct
paths = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]
for column in range(19):
for row in goldMap:
coin = row[column]
paths[column] += coin.value # the main problem
maximumPath = 0
pathToTake = None
pathNumber = 0
for i in range(len(paths)):
if paths[i] > maximumPath:
pathToTake = 14 + (distanceX * i)
hero.say(pathToTake)
pathNumber = i
hero.moveXY(pathToTake, 14) #Error "moveXY requires 2 numbers as arguments, x and y."
#What is the next bit???????
I’m not asking for a solution, I’m just asking for help, please. Thank you!