Skip to content

Commit e9b40d8

Browse files
committed
more more
1 parent a7147de commit e9b40d8

File tree

1 file changed

+12
-6
lines changed

1 file changed

+12
-6
lines changed

problem3.py

+12-6
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,15 @@ class Junction:
77
def __init__(self, number, connections):
88
self.number = number #Junction ID #
99
self.connections = connections #list of Junction's it's connected to
10+
def number_connections(self):
11+
return len(self.connections)
1012
def add_connection(self, junction):
1113
#add a connection to Junction_number
1214
self.connections.append(junction)
1315
#def remove_connection(self, junction):
1416
# self.
1517
def is_reachable(self, junction):
16-
return junction in self.connections
18+
return junction in self.connections #GOTTA CHANGE THIS
1719

1820
def assemble_network(n,network):
1921
#assemble network based on sum line
@@ -33,11 +35,15 @@ def junction_solve(n, network):
3335
for a in range(len(ordered)):
3436
for b in range(a,len(a)):
3537
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
4147

4248
for i in range(num_test_cases):
4349

0 commit comments

Comments
 (0)