Есин Никита Игоревич, 528 группа VirtualTurtle 8650 | Воробьев Егор Александрович, 419/2 (КФ) VirtualTurtle 10097 | ||||
---|---|---|---|---|---|
n | 1 | def turtle(coord, dir): | n | 1 | def turtle(coord, direction): |
2 | x, y = coord | 2 | x, y = coord | ||
3 | while True: | 3 | while True: | ||
4 | command = (yield (x, y)) | 4 | command = (yield (x, y)) | ||
5 | if command == 'f': | 5 | if command == 'f': | ||
n | 6 | if dir == 0: | n | 6 | if direction == 0: |
7 | x += 1 | 7 | x += 1 | ||
n | 8 | elif dir == 1: | n | 8 | elif direction == 1: |
9 | y += 1 | 9 | y += 1 | ||
n | 10 | elif dir == 2: | n | 10 | elif direction == 2: |
11 | x -= 1 | 11 | x -= 1 | ||
n | 12 | elif dir == 3: | n | 12 | elif direction == 3: |
13 | y -= 1 | 13 | y -= 1 | ||
14 | elif command == 'l': | 14 | elif command == 'l': | ||
n | 15 | dir = (dir + 1) % 4 | n | 15 | direction = (direction + 1) % 4 |
16 | elif command == 'r': | 16 | elif command == 'r': | ||
t | 17 | dir = (dir - 1) % 4 | t | 17 | direction = (direction - 1) % 4 |
Legends | ||||||||||
---|---|---|---|---|---|---|---|---|---|---|
|
|