def test_has_antenna(self):
        network = create_network([0,2,3,7,8,9])
        assert has_antenna(0, network)
        assert has_antenna(3, network)
        assert has_antenna(9, network)

        assert not has_antenna(4, network)
        assert not has_antenna(10, network)
def get_random_network(box_size, random, Generator):
    antenna_generator = Generator(box_size, random)
    antennas = []
    antenna, network_prob = antenna_generator.get_random_antenna()

    while antenna != -1:
        antennas.append(antenna)
        antenna, p = antenna_generator.get_random_antenna()
        network_prob *= p

    return create_network(antennas), network_prob
    def test_can_antenna_be_turned_on(self):
        # □-□-□-□-■
        # □-□-□-□-□
        # □-□-■-□-□
        # □-□-□-□-■
        # □-□-□-□-□

        network = create_network([4, 12, 20])
        assert can_antenna_be_turned_on(0, network, 5)
        assert can_antenna_be_turned_on(1, network, 5)
        assert can_antenna_be_turned_on(5, network, 5)
        assert can_antenna_be_turned_on(19, network, 5)

        assert not can_antenna_be_turned_on(3, network, 5)
        assert not can_antenna_be_turned_on(7, network, 5)
        assert not can_antenna_be_turned_on(11, network, 5)
        assert not can_antenna_be_turned_on(13, network, 5)
        assert not can_antenna_be_turned_on(17, network, 5)
 def test_turn_off_antenna(self):
     network = create_network([0,2,3,7,8,9])
     assert turn_off_antenna(2, network) == 905
     assert turn_off_antenna(7, network) == 781
     assert turn_off_antenna(10, network) == 909
     assert turn_off_antenna(4, network) == 909
 def test_create_network(self):
     assert create_network([]) == 0
     assert create_network([0,2,3,7,8,9]) == 909