Computer Science 5: Dangerous Tracks

So I’ve been trying to do this level for an hour.
I believe my code is correct, but it skips the “buildEastLine()” and “buildSouthLine()” functions.
Doe’s anybody know why?

# Protect the village with fire traps.
# Mine all passages in four directions.
# You have 80 seconds before the ogres attack.

# Build traps on the line y=114 from x=40 to x=112 with step=24.
def buildNorthLine():
    for x in range(40, 113, 24):
        hero.buildXY("fire-trap", x, 114)

# Build traps on the line x=140 from y=110 to y=38 with step=18.
def buildEastLine():
    for y in range(110, 38, 18):
        hero.buildXY("fire-trap", 140, y)

# Build traps on the line y=22 from x=132 to x=32 with step=20
def buildSouthLine():
    for x in range(132, 32, 20):
        hero.buildXY("fire-trap", x, 22)

# Build traps on the line x=20 from y=28 to y=108 with step=16.
def buildWestLine():
    for y in range(28, 108, 16):
        hero.buildXY("fire-trap", 20, y)

buildNorthLine()
buildEastLine()
buildSouthLine()
buildWestLine()
hero.moveXY(40, 94)
1 Like

Think about which way you are headed and whether your coordinate increases or decreases when stepping. Make sure your step matches the direction from start to finish range.

An extra tip: look at the first one closely, particularly the end points.

Hello and welcome to codecombat discourse! This is a cozy forum where you can share ideas, share fan art, get assistance for code, etc! Before you proceed, we hope that you review our community guidelines, which shows all essentials of this board! Thanks!