ICode国际青少年编程竞赛- Python-2级训练场-坐标与列表练习
1、
for i in range(6):Spaceship.step(Item[i].x - Spaceship.x)Dev.step(Item[i].y - Dev.y)Dev.step(Spaceship.y - Dev.y)
2、
for i in range(5):Spaceship.step(Item[i].x - Spaceship.x)Flyer[i].step(Item[i].x - Flyer[i].x)Dev.step(-6)Dev.step(6)
3、
for i in range(4):Dev.step(Item[i * 2].x - Dev.x)Dev.turnRight()Dev.step(Item[i * 2 + 1].y - Dev.y)Dev.turnLeft()
4、
for i in range(5):Flyer[i].step(Flyer[i].y - Item[2].y)Flyer[i + 5].step(Item[2].x - Flyer[i + 5].x)
Dev.step(Item[2].x - Dev.x)
Dev.turnRight()
Dev.step(Item[4].y - Dev.y)
5、
for i in range(6):Flyer[i].step(Dev.y - Flyer[i].y)
for i in range(3):Dev.step(7)Dev.turnLeft()
6、
for i in range(4):Flyer[i].step(Flyer[i].x - Dev.x)
for i in range(2):Dev.turnLeft()Dev.step(4 + i * 4)Dev.turnLeft()Dev.step(4 + i * 4)
7、
for i in range(5):Flyer[i].step(abs(Dev.y-Flyer[i].y))
Dev.step(Item[4].x - Dev.x)
8、
for i in range(8):Flyer[i].step(abs(Flyer[i].y - Dev.y))
Dev.step(Item.x - Dev.x)
9、
for i in range(5):Flyer[i].step(abs(Flyer[i].x - Dev.x))
Dev.step(Item[2].y - Dev.y)
10、
for i in range(8):Flyer[i].step(abs(Flyer[i].x - Dev.x))
Dev.step(Item[3].y - Dev.y)
11、
for i in range(4):Flyer[i].step(abs(Flyer[i].y - Item[i].y))Dev.turnLeft()Dev.step(3)Dev.turnRight()Dev.step(2)
12、
for i in range(3):Flyer[i].step(abs(Item[i].x - Flyer[i].x))Dev.step(3)Dev.step(-3)Dev.turnRight()
Dev.step(3)
13、
for i in range(6):Flyer[i].step(abs(Item[i].y - Flyer[i].y))
for i in range(3):Dev.turnLeft()Dev.step(4)Dev.turnRight()Dev.step(4)
14、
for i in range(6):Dev.step(Item[i].x - Dev.x)Dev.turnLeft()Dev.step(Dev.y - Item[i].y)Dev.step(Dev.y - 7)Dev.turnRight()
15、
for i in range(3):Flyer[i].step(abs(Dev.x - Flyer[i].x))for j in range(2):Dev.step(i * 2 + 2)Dev.turnRight()
16、
for i in range(3):Flyer[i].step(abs(Flyer[i].x - Item[i].x))Dev.step(6)Dev.turnRight()
Flyer[3].step(Item[3].x - Flyer[3].x)
Dev.step(1)
17、
for i in range(3):Flyer[i].step(Item[1].y - Flyer[i].y)Flyer[i + 3].step(abs(Flyer[i + 3].x - Item[0].x))
Dev.step(Item[1].x - Dev.x)
Dev.step(Item[0].x - Dev.x)
Dev.turnRight()
Dev.step(Item[0].y - Dev.y)
18、
for i in range(7):Spaceship.step(2)Dev.step(Item[2 * i + 1].y - Dev.y)Dev.step(Item[2 * i].y - Dev.y)Dev.step(Spaceship.y - Dev.y)
19、
for i in range(5):Flyer[i].step(abs(Item[0].x - Flyer[i].x))Flyer[i + 5].step(abs(Item[0].y - Flyer[i + 5].y))
Dev.step(Dev.y - Item[0].y)
Dev.turnRight()
Dev.step(Item[2].x - Dev.x)
20、
for i in range(4):# 方法2 找Dev的x坐标# Flyer[i*2].step(abs(Flyer[i*2].x - Item[i*2].x))Flyer[i * 2].step(abs(Flyer[2 * i].x - Dev.x))Dev.turnLeft()Dev.step(i + 2)Flyer[i * 2 + 1].step(abs(Flyer[2 * i + 1].y - Dev.y)) Dev.turnRight()Dev.step(i + 2)