Skip to content

Commit

Permalink
Tidy up Day 12.
Browse files Browse the repository at this point in the history
  • Loading branch information
pak21 committed Dec 12, 2017
1 parent 7ab510e commit b93680a
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions 12/12.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,16 +21,16 @@
groups += 1
first = all_items.pop()
todo = collections.deque([first])
seen = set()
seen = set([first])

while len(todo) > 0:
item = todo.popleft()
if item in all_items:
all_items.remove(item)
seen.add(item)
for r in connections[item]:
if not r in seen:
todo.append(r)
seen.add(r)

all_items -= seen

print('{} -> {}'.format(first, len(seen)))

Expand Down

0 comments on commit b93680a

Please sign in to comment.