@@ -7,13 +7,15 @@ class Junction:
7
7
def __init__ (self , number , connections ):
8
8
self .number = number #Junction ID #
9
9
self .connections = connections #list of Junction's it's connected to
10
+ def number_connections (self ):
11
+ return len (self .connections )
10
12
def add_connection (self , junction ):
11
13
#add a connection to Junction_number
12
14
self .connections .append (junction )
13
15
#def remove_connection(self, junction):
14
16
# self.
15
17
def is_reachable (self , junction ):
16
- return junction in self .connections
18
+ return junction in self .connections #GOTTA CHANGE THIS
17
19
18
20
def assemble_network (n ,network ):
19
21
#assemble network based on sum line
@@ -33,11 +35,15 @@ def junction_solve(n, network):
33
35
for a in range (len (ordered )):
34
36
for b in range (a ,len (a )):
35
37
if ordered [a ][b ] and not b == a :
36
-
37
- #if there is no path betweeen Junction a and b already
38
-
39
- #add a path
40
-
38
+ if not ordered [a ].is_reachable (ordered [b ]):
39
+ ordered [a ].add_connection (ordered [b ])
40
+ m = 0
41
+ path_list = []
42
+ for junction in junction_list :
43
+ m += junction .number_connections ()
44
+ for i in junction .connections :
45
+ path_list .append (junction .number , junction .connections [i ].number )
46
+ return m , path_list
41
47
42
48
for i in range (num_test_cases ):
43
49
0 commit comments