-
Notifications
You must be signed in to change notification settings - Fork 0
/
directions.py
33 lines (32 loc) · 1.28 KB
/
directions.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
class Directions:
def __init__(self,path):
self.cardinalList = []
auxNode = 0
for node in path:
if (auxNode == 0):
auxNode = node
else:
if (node[1] == auxNode[1]):
if (node[0] < auxNode[0]):
self.cardinalList.append('N')
else:
self.cardinalList.append('S')
elif (node[0] == auxNode[0]):
if (node[1] < auxNode[1]):
self.cardinalList.append('O')
else:
self.cardinalList.append('E')
elif (node[1] < auxNode[1]):
if (node[0] < auxNode[0]):
self.cardinalList.append('NO')
else:
self.cardinalList.append('SO')
elif (node[1] > auxNode[1]):
if (node[0] < auxNode[0]):
self.cardinalList.append('NE')
else:
self.cardinalList.append('SE')
auxNode = node
print(self.cardinalList)
# directions = Directions([[0, 0], [0, 1], [1, 2], [2, 3], [3, 3], [4, 2], [5, 1], [5, 0], [4, 0]])
# print(directions.cardinalList)