Enable Javascript in your browser and then refresh this page, for a much enhanced experience.
Bellman–Ford-ish (short) solution in Clear category for How to Find Friends by StefanPochmann
def check_connection(network, first, second):
team = {first}
for _ in network:
for edge in network:
pair = set(edge.split('-'))
if pair & team:
team |= pair
return second in team
April 16, 2015
Comments: