VirtualTurtle/yervandsargsyan | VirtualTurtle/sus801 | ||||
---|---|---|---|---|---|
f | 1 | def turtle(coord, direction): | f | 1 | def turtle(coord, direction): |
2 | x = coord[0] | 2 | x = coord[0] | ||
3 | y = coord[1] | 3 | y = coord[1] | ||
n | 4 | way = yield direction | n | 4 | direc = yield direction |
5 | while way: | 5 | while direc: | ||
6 | if way == 'f': | 6 | if direc == 'f': | ||
7 | if direction == 0: | 7 | if direction == 0: | ||
8 | x += 1 | 8 | x += 1 | ||
9 | elif direction == 1: | 9 | elif direction == 1: | ||
10 | y += 1 | 10 | y += 1 | ||
11 | elif direction == 2: | 11 | elif direction == 2: | ||
12 | x -= 1 | 12 | x -= 1 | ||
13 | else: | 13 | else: | ||
14 | y -= 1 | 14 | y -= 1 | ||
n | 15 | elif way == 'l': | n | 15 | elif direc == 'l': |
16 | direction = (direction+1) % 4 | 16 | direction = (direction+1) % 4 | ||
17 | else: | 17 | else: | ||
18 | if direction == 0: | 18 | if direction == 0: | ||
19 | direction = 3 | 19 | direction = 3 | ||
20 | elif direction == 1: | 20 | elif direction == 1: | ||
21 | direction = 0 | 21 | direction = 0 | ||
22 | elif direction == 2: | 22 | elif direction == 2: | ||
23 | direction = 1 | 23 | direction = 1 | ||
24 | else: | 24 | else: | ||
25 | direction = 2 | 25 | direction = 2 | ||
t | 26 | way = yield(x, y) | t | 26 | direc = yield(x, y) |
27 | 27 |
Legends | ||||||||||
---|---|---|---|---|---|---|---|---|---|---|
|
|