Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- def printM(A):
- for elem in A:
- print(*elem)
- kor = [0, 0]
- data = [kor]
- to = [0, 1]
- comands = list(input())
- k = 0
- for comand in comands:
- if comand == 'R':
- if to == [0,1]:
- to = [1,0]
- elif to == [1, 0]:
- to = [0, -1]
- elif to == [0, -1]:
- to = [-1, 0]
- elif to == [-1, 0]:
- to = [0, 1]
- elif comand == 'L':
- if to == [0,1]:
- to = [-1,0]
- elif to == [1, 0]:
- to = [0, 1]
- elif to == [0, -1]:
- to = [1, 0]
- elif to == [-1, 0]:
- to = [0, -1]
- elif comand == 'S':
- kor = [kor[0] + to[0], kor[1] + to[1]]
- k += 1
- if kor in data:
- print(k)
- break
- data.append(kor)
- else:
- print(-1)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement