ICode国际青少年编程竞赛- Python-5级训练场-综合练习7
1、
for i in range(6):
while not Flyer[i].disappear():
wait()
Spaceship.step(2 + 2 * i)
Spaceship.turnRight()
2、
def get(a, b, c, d):
for i in (a, b, c, d):
Dev.step(i)
if i != 0:
Dev.turnRight()
get(3, 3, 5, -4)
get(5, 4, 10, -1)
get(3, 4, 5, 4)
get(-4, -4, -8, 9)
get(-4, 2, 0, 0)
3、
for i in range(6):
Spaceship.step(2)
if i % 2 == 0:
Spaceship.turnLeft()
else:
Spaceship.turnRight()
while not Flyer[i].disappear():
wait()
Spaceship.step(abs(7 - Item[i].y))
Spaceship.turnLeft()
Spaceship.turnLeft()
Spaceship.step(abs(7 -Spaceship.y) - 2)
while not Flyer[i].disappear():
wait()
Spaceship.step(2)
if i % 2 == 0:
Spaceship.turnLeft()
else:
Spaceship.turnRight()
4、
for i in range(5):
Dev.step(5 - i)
while Item[i * 2].y != Dev.y or Item[i * 2].x != Dev.x:
wait()
Dev.step(1)
while Item[i * 2 + 1].y != Dev.y or Item[i * 2 + 1].x != Dev.x:
wait()
Dev.step(5 - i)
Dev.wait(10)
Dev.turnRight()
5、
def get(a, b, c, d, e):
Dev.step(a)
Dev.turnRight()
Dev.step(b)
Dev.turnLeft()
Spaceship.step(c)
Spaceship.turnLeft()
Spaceship.step(c)
Dev.step(d)
Spaceship.turnRight()
Spaceship.step(e)
get(4, 3, 3, -1, 4)
get(3, 2, 2, -1, 0)
Spaceship.turnRight()
Spaceship.step(3)
Spaceship.turnRight()
get(-5, -4, 4, 1, 2)
get(-2, -1, 0, 0, 0)
6、
def get(a, b, c):
for i in range(a):
Dev.step(b - i)
Dev.turnLeft()
Dev.step(c)
get(5, 6, 5)
for i in range(2):
Dev.turnRight()
Dev.step(i + 4)
Dev.turnLeft()
get(5, 6, 12)
Dev.turnLeft()
get(4, 5, 5)
7、
def get(a, b, c, d):
Spaceship.step(a)
Dev.step(b)
Dev.turnRight()
Dev.step(c)
Dev.turnLeft()
Dev.step(d)
Dev.step(-d)
Dev.turnRight()
Dev.step(-c)
Dev.turnLeft()
Dev.step(-b)
get(4, 3, -2, -1)
get(2, 6, 2, -1)
get(4, 3, -2, -1)
get(4, 3, -2, -1)
get(2, 6, 2, -1)
8、
for i in range(3):
Dev.step(i + 2)
while Flyer[2 - i].disappear():
wait()
Dev.step(2)
Dev.wait(10)
Dev.step(2)
for j in range(2):
Dev.turnRight()
Dev.step(3)
if i != 2:
Dev.turnRight()
Dev.step(2)
Dev.wait(10)
while Flyer[2 - i].disappear():
wait()
Dev.step(i + 5)
Dev.turnRight()
9、
for i in range(4):
Spaceship.step(6)
Spaceship.turnRight()
while not Flyer[i].disappear():
wait()
Spaceship.step(2)
Dev.step(-1)
for j in range(4):
Dev.step(-3)
Dev.turnLeft()
Dev.step(1)
Spaceship.turnLeft()
Spaceship.turnLeft()
while not Flyer[i].disappear():
wait()
for j in range(2):
Spaceship.step(2 + j * 4)
Spaceship.turnRight()
Dev.turnRight()
10、
for i in range(4):
while Flyer[3 - i].disappear():
wait()
Dev.step(-2)
if i != 3:
Dev.turnLeft()
for j in range(4):
Dev.step(6 - i * 2)
Dev.wait(10)
Dev.turnLeft()
Dev.step(6 - i * 2)
Dev.turnRight()
11、
def get(a, b):
for i in range(3):
while Flyer[a + i].disappear():
wait()
Dev.step(2)
for j in range(4):
Dev.step(b)
Dev.turnRight()
while Flyer[a + i].disappear():
wait()
Dev.step(-2)
Dev.turnRight()
get(0, 1)
Dev.step(1)
Spaceship.turnRight()
Spaceship.step(5)
Spaceship.turnLeft()
Spaceship.step(6)
Dev.turnRight()
Dev.step(-1)
Dev.turnRight()
get(3, 2)
12、
def get(a, b, c):
Spaceship.step(a)
Dev.step(b)
Dev.wait(10)
Dev.step(c)
Dev.step(-c)
Dev.wait(10)
Dev.step(-b)
get(5, 5, 1)
Spaceship.turnLeft()
Dev.turnLeft()
get(6, 6, 0)
Spaceship.turnRight()
Dev.turnLeft()
get(2, -3, -3)
Dev.turnLeft()
Spaceship.turnRight()
Spaceship.step(1)
Spaceship.turnRight()
get(6, -2, -4)
13、
for i in range(3):
for j in range(2):
Spaceship.step(5 - j)
Spaceship.turnLeft()
Spaceship.step(i + 2)
while not Flyer[2 - i].disappear():
wait()
Spaceship.step(2)
Dev.step(-1)
Dev.step(1)
Dev.turnLeft()
Dev.step(1)
for j in range(4):
Dev.step(2)
Dev.turnRight()
Dev.step(-1)
Dev.turnRight()
Spaceship.turnRight()
Spaceship.turnRight()
while not Flyer[2 - i].disappear():
wait()
Spaceship.step(i + 4)
14、
def get(a, b, c):
Dev.step(a)
Dev.turnRight()
Dev.step(b)
Dev.turnLeft()
Spaceship.step(b)
Dev.step(-a)
Spaceship.step(c)
get(3, 3, 0)
get(-4, 2, 2)
Spaceship.turnRight()
Dev.turnRight()
get(6, 3, 3)
Spaceship.turnRight()
Dev.turnRight()
Spaceship.step(1)
get(2, 3, 0)
15、
def get(a, b, c, d):
Dev.step(a)
Dev.turnRight()
Dev.step(b)
Dev.turnLeft()
Dev.step(c)
Spaceship.step(b)
Dev.step(-c-a)
Spaceship.step(d)
get(3, 2, 3, 3)
get(4, 3, 1, 0)
for i in range(2):
Dev.turnRight()
Spaceship.turnRight()
Spaceship.step(2)
get(i + 2, i + 1, 2, 0)
16、
def get(a, b, c):
Flyer[c].step(1)
Spaceship.step(a)
for i in range(4):
Dev.step(b)
Dev.turnRight()
get(2, 2, 2)
Spaceship.turnRight()
get(4, -5, 3)
Spaceship.turnLeft()
Dev.turnLeft()
get(4, -3, 1)
Spaceship.turnLeft()
Dev.turnRight()
get(4, 6, 0)
17、
def get(a, b, c, d, e):
Spaceship.step(a)
for i in range(3):
Flyer[b + i].step(c)
Dev.step(d)
Dev.turnRight()
Dev.step(e)
Dev.turnLeft()
Spaceship.step(e)
Dev.step(-d)
Spaceship.step(3)
Spaceship.turnLeft()
get(3, 3, 2, 3, 1)
Spaceship.step(2)
Spaceship.turnRight()
Dev.turnRight()
get(0, 0, 1, 4, 2)
Spaceship.step(3)
Spaceship.turnRight()
Dev.turnRight()
get(2, 6, 4, 3, 5)
18、
for i in range(4):
Spaceship.step(1)
Dev.step(1)
Dev.turnLeft()
Dev.step(7 - i)
Dev.wait(10)
Dev.turnRight()
Dev.wait(10)
while Flyer[i * 2].disappear():
wait()
Dev.step(2)
Dev.turnLeft()
Dev.wait(10)
Dev.step(i + 3)
Dev.turnRight()
Spaceship.step(10)
while Flyer[i * 2 + 1].disappear():
wait()
Dev.step(-3)
Spaceship.step(3)
Spaceship.turnRight()
Dev.turnRight()
19、
Spaceship.step(4)
Spaceship.turnRight()
for i in range(3):
while not Flyer[i * 2].disappear():
wait()
Spaceship.step(i + 4)
Spaceship.turnRight()
while not Flyer[i * 2 + 1].disappear():
wait()
Spaceship.step(i + 4)
for j in range(3):
Spaceship.turnRight()
Spaceship.step(i + 2)
20、
for i in range(4):
while Flyer[i].disappear():
wait()
Dev.step(i + 4)
while Item[i].x != Dev.x or Item[i].y != Dev.y:
wait()
for j in range(3):
Dev.turnRight()
Dev.step(i + 2)
Dev.turnRight()
while Flyer[i].disappear():
wait()
Dev.step(-2)
Dev.turnRight()
Spaceship.step(3)
Spaceship.turnRight()