• mission idea "Power Supply"

Question related to mission Power Supply

 

I made one-bite-mission "Power Supply".

Probably I think that CheckiO dose not have same kind of mission. I would like to get some feedback.

description: You are given power networks and power-plant's information (plant-number and supply-range). You should find out blackout cities. Power-plant can supply himself and connected cities with power. but the range is limited.

specification: powersupply({(city0, city1), (city0, power-plant1),..}, {(power-plant1, supply-range),..}) == [blackout-city_1,..]

ex: power_supply({(0, 1), (0, 2), (1, 3), (2, 4)}, {(2, 1)}) == [1, 3]

*The blackout-cities should be represented as a list of integers in ascending order.

code & test

def power_supply(networks, power_plants):

    return blackout-cities

if __name__ == '__main__':
    assert power_supply({(0, 1), (1, 2)}, {(0, 1)}) == [2], 'one blackout'
    assert power_supply({(0, 1), (0, 2), (1, 3), (2, 4)}, {(2, 1)}) == [1, 3], 'two blackout'
    assert power_supply({(0, 1), (1, 2), (2, 3)}, {(0, 3)}) == [], 'no blackout'
    assert power_supply({(0, 1), (1, 2)}, {(1, 0)}) == [0, 2], 'weak power-plant'
    assert power_supply({(0, 1), (0, 2), (2, 3), (3, 4), (4, 5)}, {(0, 1), (4, 1)}) == [], 'cooperation'
    assert power_supply({(0, 1), (1, 2), (2, 3), (2, 4), (4, 5), (5, 6), (5, 7)},
                        {(1, 1), (7, 1)},) == [3, 4, 6], 'complex cities 1'
    assert power_supply({(0, 1), (0, 2), (0, 3), (0, 4), (4, 9), (4, 10), (10, 11),
                         (11, 12), (2, 5), (2, 6), (5, 7), (5, 8)},
                        {(0, 1), (12, 4), (8, 1)},) == [6, 7], 'complex cities 2'