Enable Javascript in your browser and then refresh this page, for a much enhanced experience.
Power Supply solution in Clear category for Power Supply by sedoy80
def power_supply(network, power_plants):
network = [set(connection) for connection in network]
power_nets = []
for power_name, deep in power_plants.items():
power_net = {power_name}
for i in range(int(deep)):
net_to_append = set()
for connection in network:
if not connection.isdisjoint(power_net):
net_to_append.update(connection)
power_net.update(net_to_append)
power_nets.append(power_net)
cities = set().union(*network)
cities.difference_update(*power_nets)
return list(cities)
Dec. 15, 2016
Comments: