Тишина Ульяна Кирилловна, 411 VirtualTurtle 9015 | Кочармин Михаил Дмитриевич, 527 группа VirtualTurtle 8701 | ||||
---|---|---|---|---|---|
n | 1 | def turtle(a, d): | n | 1 | def turtle(coord, direction): |
2 | x, y = a | 2 | x, y = coord | ||
3 | while True: | 3 | while True: | ||
n | 4 | command = (yield (x, y)) | n | 4 | cmd = (yield (x, y)) |
5 | if command == 'f': | 5 | if cmd == 'f': | ||
6 | if d == 0: | 6 | if direction == 0: | ||
7 | x += 1 | 7 | x += 1 | ||
n | 8 | elif d == 1: | n | 8 | elif direction == 1: |
9 | y += 1 | 9 | y += 1 | ||
n | 10 | elif d == 2: | n | 10 | elif direction == 2: |
11 | x -= 1 | 11 | x -= 1 | ||
n | 12 | elif d == 3: | n | 12 | elif direction == 3: |
13 | y -= 1 | 13 | y -= 1 | ||
t | 14 | elif command == 'l': | t | 14 | elif cmd == 'l': |
15 | d = (d + 1) % 4 | 15 | direction = (direction + 1) % 4 | ||
16 | elif command == 'r': | 16 | elif cmd == 'r': | ||
17 | d = (d - 1 + 4) % 4 | 17 | direction = (direction + 4 - 1) % 4 |
Legends | ||||||||||
---|---|---|---|---|---|---|---|---|---|---|
|
|