Enable Javascript in your browser and then refresh this page, for a much enhanced experience.
8 lines solution in Clear category for Power Supply by kdim
def power_supply(network, power_plants):
nodes, connected = set(sum(network, [])), set()
for plant, power in power_plants.items():
connect = set([plant])
for _ in range(power):
connect |= set(i[n == i[0]] for i in network for n in connect if n in i)
connected |= connect
return nodes - connected
Feb. 4, 2021