Исанбеков Дамир 414 КФ VirtualTurtle 11374
Абдикашева Вилена Ринатовна, 411 группа VirtualTurtle 10206
n1def turtle(start_position, start_direction):n1def turtle(position, initial_direction):
2    current_x, current_y = start_position2    pos_x, pos_y = position
3    direction_steps = [(1, 0), (0, 1), (-1, 0), (0, -1)]3    moves = [(1, 0), (0, 1), (-1, 0), (0, -1)]
4    current_direction = start_direction4    facing = initial_direction
5    while True:5    while True:
n6        command = (yield (current_x, current_y))n6        command = (yield (pos_x, pos_y))
7        if command == 'f':7        if command == 'f':
n8            dx, dy = direction_steps[current_direction]n8            move_x, move_y = moves[facing]
9            current_x += dx9            pos_x += move_x
10            current_y += dy10            pos_y += move_y
11        elif command == 'l':11        elif command == 'l':
n12            current_direction = (current_direction + 1) % 4n12            facing = (facing + 1) % 4
13        elif command == 'r':13        elif command == 'r':
t14            current_direction = (current_direction - 1) % 4t14            facing = (facing - 1) % 4
Legends
Colors
 Added 
Changed
Deleted
Links
(f)irst change
(n)ext change
(t)op