| f | def turtle(coord, direction): | f | def turtle(coord, direction): | 
            | n | directions = [(1, 0), (0, 1), (-1, 0), (0, -1)] | n | mas = [(1, 0), (0, 1), (-1, 0), (0, -1)] | 
            |  | x, y = coord |  | x, y = coord | 
            |  | while True: |  | while True: | 
            | n | command = (yield (x, y)) | n | pos = (yield (x, y)) | 
            |  | if command == 'f': |  | if pos == 'f': | 
            |  | dx, dy = directions[direction] |  | dx, dy = mas[direction] | 
            |  | x += dx |  | x += dx | 
            |  | y += dy |  | y += dy | 
            | n | elif command == 'l': | n | elif pos == 'l': | 
            |  | direction = (direction + 1) % 4 |  | direction = (direction + 1) % 4 | 
            | t | elif command == 'r': | t | elif pos == 'r': | 
            |  | direction = (direction - 1) % 4 |  | direction = (direction - 1) % 4 |