VirtualTurtle/anna9829 | VirtualTurtle/Ronikita98.07 | ||||
---|---|---|---|---|---|
f | 1 | def turtle(coord, d): | f | 1 | def turtle(coord, d): |
2 | a = [] | 2 | a = [] | ||
3 | a.append(coord[0]) | 3 | a.append(coord[0]) | ||
4 | a.append(coord[1]) | 4 | a.append(coord[1]) | ||
5 | x = yield a[0], a[1] | 5 | x = yield a[0], a[1] | ||
n | 6 | while True: | n | 6 | while x: |
7 | if x == 'f': | 7 | if x == 'f': | ||
8 | if d == 0: | 8 | if d == 0: | ||
9 | a[0] += 1 | 9 | a[0] += 1 | ||
10 | x = yield a[0], a[1] | 10 | x = yield a[0], a[1] | ||
11 | elif d == 1: | 11 | elif d == 1: | ||
12 | a[1] += 1 | 12 | a[1] += 1 | ||
13 | x = yield a[0], a[1] | 13 | x = yield a[0], a[1] | ||
14 | elif d == 2: | 14 | elif d == 2: | ||
15 | a[0] -= 1 | 15 | a[0] -= 1 | ||
16 | x = yield a[0], a[1] | 16 | x = yield a[0], a[1] | ||
17 | elif d == 3: | 17 | elif d == 3: | ||
18 | a[1] -= 1 | 18 | a[1] -= 1 | ||
19 | x = yield a[0], a[1] | 19 | x = yield a[0], a[1] | ||
20 | elif x == 'l': | 20 | elif x == 'l': | ||
21 | d = (d+1) % 4 | 21 | d = (d+1) % 4 | ||
22 | x = yield a[0], a[1] | 22 | x = yield a[0], a[1] | ||
23 | elif x == 'r': | 23 | elif x == 'r': | ||
24 | d = (d-1) % 4 | 24 | d = (d-1) % 4 | ||
25 | x = yield a[0], a[1] | 25 | x = yield a[0], a[1] | ||
26 | 26 | ||||
t | 27 | t | |||
28 | #robo = turtle((0,0),0) | ||||
29 | #start = next(robo) | ||||
30 | # for c in "flfrffrffr": | ||||
31 | # print(*robo.send(c)) | ||||
32 |
Legends | ||||||||||
---|---|---|---|---|---|---|---|---|---|---|
|
|