day 8p2 done! + some cleaning to p1

This commit is contained in:
2025-12-08 07:18:05 +00:00
parent b580c8b9d6
commit a62109f1e9
2 changed files with 64 additions and 5 deletions

View File

@@ -47,15 +47,15 @@ if __name__ == "__main__":
graph, num_vertices = build_graph()
graph.sort(key=lambda x: x[2])
dsu = DSU(num_vertices)
conns = 0
attempted = 0
for u, v, w in graph:
attempted += 1
if dsu.union(u, v):
if attempted >= 1000:
break
dsu.union(u, v)
if attempted >= DESIRED_CONNS:
break
print(f"Attempted edges: {attempted}, Connections made: {conns}")
component_sizes = {}
for i in range(num_vertices):
root = dsu.find(i)