Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/usr/bin/python
- import sys
- from itertools import permutations
- def sanitize(st):
- _st = st
- for ch in ["(", ")", "[", "]", "'"]:
- _st = _st.replace(ch, "")
- return _st.replace(", ", ",").replace("\\n", "|")
- user_pos = []
- pois = []
- i = 0
- for line in sys.stdin:
- if i == 0:
- user_pos = line.split(",")
- #user_pos = [float(v) for v in user_pos]
- i = 1
- else:
- poi = line.split(",")
- pois.append(poi)
- possible_paths = map(list, permutations(pois))
- if len(pois) % 2 == 0:
- for path in possible_paths:
- path.append(path[-1])
- for path in possible_paths:
- if path[0] != user_pos and path[1] != user_pos:
- print sanitize("%s%s"%(str(user_pos), str(path))).replace("|,", "|").strip("|")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement