憤怒鳥抓豬遊戲解答


連結: 憤怒鳥抓豬遊戲

1.
moveForward();
moveForward();
2.
moveForward();
moveForward();
moveForward();
3.
moveForward();
moveForward();
turnRight();
moveForward();
4.
moveForward();
turnLeft();
moveForward();
turnRight();
moveForward();
5.
turnRight();
moveForward();
turnLeft();
moveForward();
moveForward();
moveForward();
turnLeft();
moveForward();
6.
for (var count = 0; count < 5; count++) {
    moveForward();
}
7.
turnRight();
for (var count = 0; count < 5; count++) {
    moveForward();
}
8.
for (var count = 0; count < 4; count++) {
    moveForward();
}
turnLeft();
for (var count2 = 0; count2 < 5; count2++) {
    moveForward();
}
9.
for (var count2 = 0; count2 < 3; count2++) {
    for (var count = 0; count < 2; count++) {
        moveForward();
    }
    turnRight();
}
10.
while (notFinished()) {
    moveForward();
}
11.
while (notFinished()) {
    moveForward();
    moveForward();
    turnLeft();
}
12.
while (notFinished()) {
    moveForward();
    turnLeft();
    moveForward();
    turnRight();
}
13.
while (notFinished()) {
    turnRight();
    moveForward();
    turnLeft();
    moveForward();
}
14.
while (notFinished()) {
    moveForward();
    if (isPathLeft()) {
        turnLeft();
    }
}
15.
while (notFinished()) {
    moveForward();
    if (isPathRight()) {
        turnRight();
    }
}
16.
while (notFinished()) {
    moveForward();
    if (isPathLeft()) {
        turnLeft();
    }
}
17.
while (notFinished()) {
    moveForward();
    if (isPathRight()) {
        turnRight();
    }
}
18.
while (notFinished()) {
    if (isPathForward()) {
        moveForward();
    } else {
        turnLeft();
    }
}
19.
while (notFinished()) {
    if (isPathForward()) {
        moveForward();
    } else {
        turnRight();
    }
}
20.
while (notFinished()) {
    if (isPathForward()) {
        moveForward();
    } else {
        if (isPathRight()) {
            turnRight();
        } else {
            turnLeft();
        }
    }
}
#運算思維






你可能感興趣的文章

使用 AntV 製作資料圖表-台灣老年人口與長照機構供需比

使用 AntV 製作資料圖表-台灣老年人口與長照機構供需比

Day 65 留言板 - Part 1

Day 65 留言板 - Part 1

python迴圈

python迴圈






留言討論