Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- for i in input:
- o = 0
- p = False
- a = i.split()
- c = 0
- #start position
- x = 0
- y = 0
- for j in i:
- if j != " ":
- if j == "R":
- x += 1
- if j == "L":
- x -= 1
- if j == "U":
- y += 1
- if j == "D":
- y -= 1
- o += 1
- res = str(x) + " " + str(y)
- if o == len(a):
- p = True
- while p == True:
- a = res.split()
- x = int(a[0])
- y = int(a[1])
- for k in range(o):
- if x != 0:
- if x > 0:
- x -= 1
- if x < 0:
- x += 1
- c += 1
- if y != 0:
- if y > 0:
- y -= 1
- if y < 0:
- y += 1
- c += 1
- if p == False:
- break
- if x == 0 and y == 0:
- print(c)
- p = False
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement