ICode国际青少年编程竞赛- Python-2级训练场-坐标与列表遍历
1、
for i in range(5):Flyer[i].step(Dev.x -Flyer[i].x)
Dev.step(Item.y - Dev.y)
2、
for i in range(7):Flyer[i].step(Dev.y - Flyer[i].y)
Dev.step(Item[2].x - Dev.x)
3、
for i in range(5):Flyer[i].step(Dev.y - Flyer[i].y)
Dev.step(Item[1].x - Dev.x)
4、
for i in range(4):Spaceship.step(2)d = Item[i].x -Dev.xDev.step(d)Dev.step(-d)
5、
for i in range(5):Spaceship.step(2)d = Item[i].x - Dev.xDev.step(d)Dev.step(-d)
6、
for i in range(4):Dev.step(i + 1)Dev.turnLeft()d = Item[i].x - Dev.xDev.step(d)Dev.step(-d)Dev.turnRight()
7、
for i in range(5):Spaceship.step(3)d = Item[i].x - Dev.xDev.step(d)Dev.step(-d)
8、
Dev.turnLeft()
for i in range(3):Spaceship.step(2)d = Dev.y - Item[i].yDev.step(d)Dev.step(-d)
9、
for i in range(4):Spaceship.step(i + 1)d = Item[i].x - Dev.xDev.step(d)Dev.step(-d)
10、
for i in range(4):# 飞船的移动步数是飞船到item之间y坐标的差值Spaceship.step(Spaceship.y-Item[i].y)Dev.step(Item[i].x -Spaceship.x)# 飞船的x值是不变的,为2,下面的坐标公式可以修改为(Spaceship.x - Item[i].x)或者(2-Item[i].x)Dev.step(Spaceship.x - Item[i].x)
11、
for i in range(5):Spaceship.step(Spaceship.y - Item[i].y)Dev.step(Item[i].x - Spaceship.x)Dev.step(Spaceship.x - Item[i].x)
12、
for i in range(8):Flyer[i].step(Dev.y - Flyer[i].y)
Dev.step(Item[2].x - Dev.x)
13、
for i in range(4):Dev.step(Item[i].x - Dev.x)Dev.turnRight()Dev.step(Item[i].y - Dev.y)Dev.step(1 - Dev.y)Dev.turnLeft()
14、
for i in range(6):Flyer[i].step(Dev.y - Flyer[i].y)
Dev.step(Item[4].x - Dev.x)
15、
for i in range(5):Dev.step(Spaceship.y - Item[i].y)Dev.step(Item[i].y - Spaceship.y)Spaceship.step(2)
16、
for i in range(5):Flyer[i].step(Flyer[i].x - Dev.x)
Dev.step(Dev.y - Item[0].y)
17、
for i in range(7):Spaceship.step(Item[i].x - Spaceship.x)Spaceship.turnLeft()Spaceship.step(Spaceship.y - Item[i].y)Spaceship.turnLeft()Spaceship.turnLeft()Spaceship.step(9 - Spaceship.y)Spaceship.turnLeft()
18、
Dev.turnLeft()
for i in range(3):Spaceship.step(2)Dev.step(Spaceship.y - Item[i * 2].y)Dev.step(Dev.y - Item[i * 2 + 1].y)Dev.step(Dev.y - Spaceship.y)
19、
for i in range(4):Spaceship.step(Item[i].x - Spaceship.x)Dev.step(Item[i].y - Spaceship.y)Dev.step(Spaceship.y - Dev.y)
20、
for i in range(3):Dev.step(Item[i * 2].y - Dev.y)Flyer.step(Item[i * 2].y - Flyer.y)Dev.turnLeft()Dev.step(Item[i * 2].x - Dev.x)Dev.step(Item[i * 2 + 1].x - Dev.x)Dev.turnRight()Dev.step(Item[i * 2 + 1].y - Dev.y)Dev.step(Flyer.y - Dev.y)Dev.turnRight()Dev.step(Dev.x - Flyer.x + 1)Dev.turnLeft()