From 2dea2ed0c1aa9a2b5dbd57a770a388871907a2b0 Mon Sep 17 00:00:00 2001 From: Ilya Zverev Date: Thu, 19 Oct 2017 17:54:06 +0300 Subject: [PATCH] Check all route variant for used stations --- subway_structure.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/subway_structure.py b/subway_structure.py index 460752e..540b484 100644 --- a/subway_structure.py +++ b/subway_structure.py @@ -299,6 +299,9 @@ class RouteMaster: def __get__(self, i): return self.routes[i] + def __iter__(self): + return iter(self.routes) + class City: def __init__(self, row): @@ -494,8 +497,9 @@ class City: unused_stations = set(self.station_ids) for rmaster in self.routes.values(): networks[str(rmaster.network)] += 1 - for st in rmaster.best.stops: - unused_stations.discard(st.id) + for route in rmaster: + for st in route.stops: + unused_stations.discard(st.id) if unused_stations: self.unused_stations = len(unused_stations) self.warn('{} unused stations: {}'.format(