ICode国际青少年编程竞赛- Python-2级训练场-坐标与列表遍历

ICode国际青少年编程竞赛- Python-2级训练场-坐标与列表遍历

1、

python 复制代码
for i in range(5):
    Flyer[i].step(Dev.x -Flyer[i].x)
Dev.step(Item.y - Dev.y)

2、

python 复制代码
for i in range(7):
    Flyer[i].step(Dev.y - Flyer[i].y)
Dev.step(Item[2].x - Dev.x)

3、

python 复制代码
for i in range(5):
    Flyer[i].step(Dev.y - Flyer[i].y)
Dev.step(Item[1].x - Dev.x)

4、

python 复制代码
for i in range(4):
    Spaceship.step(2)
    d = Item[i].x -Dev.x
    Dev.step(d)
    Dev.step(-d)

5、

python 复制代码
for i in range(5):
    Spaceship.step(2)
    d = Item[i].x - Dev.x
    Dev.step(d)
    Dev.step(-d)

6、

python 复制代码
for i in range(4):
    Dev.step(i + 1)
    Dev.turnLeft()
    d = Item[i].x - Dev.x
    Dev.step(d)
    Dev.step(-d)
    Dev.turnRight()

7、

python 复制代码
for i in range(5):
    Spaceship.step(3)
    d = Item[i].x - Dev.x
    Dev.step(d)
    Dev.step(-d)

8、

python 复制代码
Dev.turnLeft()
for i in range(3):
    Spaceship.step(2)
    d = Dev.y - Item[i].y
    Dev.step(d)
    Dev.step(-d)

9、

python 复制代码
for i in range(4):
    Spaceship.step(i + 1)
    d = Item[i].x - Dev.x
    Dev.step(d)
    Dev.step(-d)

10、

python 复制代码
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、

python 复制代码
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、

python 复制代码
for i in range(8):
    Flyer[i].step(Dev.y - Flyer[i].y)
Dev.step(Item[2].x - Dev.x)

13、

python 复制代码
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、

python 复制代码
for i in range(6):
    Flyer[i].step(Dev.y - Flyer[i].y)
Dev.step(Item[4].x - Dev.x)

15、

python 复制代码
for i in range(5):
    Dev.step(Spaceship.y - Item[i].y)
    Dev.step(Item[i].y - Spaceship.y)
    Spaceship.step(2)

16、

python 复制代码
for i in range(5):
    Flyer[i].step(Flyer[i].x - Dev.x)
Dev.step(Dev.y - Item[0].y)

17、

python 复制代码
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、

python 复制代码
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、

python 复制代码
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、

python 复制代码
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()
相关推荐
星辰大海的精灵2 分钟前
基于Dify+MCP实现通过微信发送天气信息给好友
人工智能·后端·python
精灵vector7 分钟前
Agent短期记忆的几种持久化存储方式
人工智能·python
北京_宏哥22 分钟前
🔥Python零基础从入门到精通详细教程4-数据类型的转换- 上篇
前端·python·面试
乾巫宇宙国监察特使32 分钟前
Python的设计模式
python·测试
Hockor41 分钟前
写给前端的 Python 教程四(列表/元组)
前端·后端·python
这里有鱼汤1 小时前
熟练掌握MACD这8种形态,让你少走三年弯路(附Python量化代码)| 建议收藏
后端·python
404.Not Found1 小时前
Day46 Python打卡训练营
开发语言·python
love530love1 小时前
【PyCharm必会基础】正确移除解释器及虚拟环境(以 Poetry 为例 )
开发语言·ide·windows·笔记·python·pycharm
运维开发王义杰1 小时前
Python: 告别 ModuleNotFoundError, 解决 pipx 环境下 sshuttle 缺少 pydivert 依赖的终极指南
开发语言·python
DanCheng-studio2 小时前
毕设 基于机器视觉的驾驶疲劳检测系统(源码+论文)
python·毕业设计·毕设