ICode国际青少年编程竞赛- Python-3级训练场-循环次数判断1
1、
for i in range(4):
Dev.step(1)
Dev.turnLeft()
Dev.step(i+1)
if i == 2:
Spaceship.step(2)
Spaceship.turnRight()
Spaceship.turnRight()
Spaceship.step(2)
Dev.step(-i-1)
Dev.turnRight()
Dev.step(1)
2、
for i in range(4):
Dev.step(-3-i)
if i == 1:
Spaceship.step(2)
Spaceship.turnRight()
Spaceship.turnRight()
Spaceship.step(2)
Dev.step(3 + i)
Dev.turnRight()
3、
for i in range(6):
Spaceship.step()
if i != 3:
Dev.step(3)
Dev.step(-3)
Spaceship.turnLeft()
Spaceship.step(2)
Spaceship.turnRight()
4、
for i in range(6):
Dev.step(2)
Dev.turnRight()
Dev.step(2)
if i != 2:
Dev.step(2)
Dev.step(-2)
Dev.turnLeft()
5、
for i in range(6):
if i != 4 and i != 5:
Dev.step(4)
Dev.step(-4)
Spaceship.step(2)
Spaceship.turnRight()
Spaceship.step(2)
Spaceship.turnLeft()
6、
for i in range(7):
Spaceship.step(i+1)
Spaceship.turnRight()
if i != 0 and i != 1 and i != 6:
Dev.step(-2)
Dev.step(2)
Dev.turnRight()
7、
for i in range(5):
Dev.turnLeft()
Dev.step(i + 1)
Dev.turnRight()
Dev.step(i + 1)
if i in (0, 1, 2):
Dev.step()
Dev.step(-1)
8、
for i in range(5):
Spaceship.turnLeft()
Spaceship.step(2+i)
if i != 0:
Dev.step(-2)
Dev.step(2)
Dev.turnLeft()
9、
for i in range(5):
if i in (0, 1, 2):
Dev.step(3)
Dev.turnRight()
Spaceship.step(3)
Spaceship.turnLeft()
Spaceship.step(3)
Spaceship.turnRight()
if i in (0, 1, 2):
Dev.step(3)
Dev.turnLeft()
10、
for i in range(7):
Dev.step(i+1)
Dev.turnRight()
if i in (3, 4, 5, 6):
Dev.step(-2)
Dev.step(2)
11、
for i in range(5):
Spaceship.step(2)
Spaceship.turnRight()
if i > 1:
Dev.step(i-1)
Dev.step(1-i)
Spaceship.step(2)
Spaceship.turnLeft()
12、
for i in range(5):
Dev.step(i+1)
Dev.turnRight()
Spaceship.step(6)
Dev.turnRight()
Dev.step(6)
13、
for i in range(5):
Dev.step(2)
Dev.turnLeft()
Dev.step(3)
if i != 3 and i != 4:
Dev.step(-3)
Dev.turnRight()
14、
for i in range(4):
Dev.step(4)
if i != 3:
Dev.step(-4)
Dev.turnRight()
Dev.turnRight()
Dev.step(4)
15、
for i in range(7):
Dev.step(2)
Dev.turnRight()
Dev.step(2)
if i != 2:
Dev.step(-1)
Dev.turnLeft()
16、
for i in range(6):
Dev.step(2+i)
# 2 3 4
# 3 2 1
if i in (2, 3, 4):
Dev.step(5-i)
Dev.step(i-5)
Dev.turnRight()
17、
for i in range(5):
Dev.step(2)
Dev.turnLeft()
Dev.step(-3)
Dev.step(3)
if i in (2, 3, 4):
Dev.step(i-1)
Dev.step(1-i)
Dev.turnRight()
18、
Dev.step()
for i in range(3):
Dev.step(i+2)
Dev.turnLeft()
Dev.step(i+1)
Dev.step(-1-i)
Dev.turnRight()
Dev.step(-2-i)
Spaceship.step()
Spaceship.turnLeft()
Spaceship.step()
if i != 2:
Spaceship.turnRight()
Spaceship.step()
Spaceship.step(4)
Dev.step()
Dev.turnRight()
Dev.step()
19、
for i in range(3):
Spaceship.step(3)
Spaceship.turnLeft()
Spaceship.step(3)
Spaceship.turnRight()
if i != 1:
Dev.step(i+1)
Dev.step(-1-i)
Dev.turnLeft()
Dev.step(i+1)
Dev.step(-1-i)
Dev.turnRight()
Spaceship.step(3)
20、
Dev.turnLeft()
for i in range(4):
Spaceship.step(3)
Spaceship.turnLeft()
Spaceship.step(3)
Spaceship.turnRight()
if i != 1:
Dev.step(3)
Dev.turnLeft()
Dev.step()
Dev.step(-1)
Dev.turnRight()
Dev.step(-3)