Exemplo n.º 1
0
    def compute_sequence(self, with_rule):
        # [start, end)
        max_sequence = Range()
        start = 0 
        end = 0

        for i in range(len(self.__complex_numbers)):
            if(with_rule(self.__complex_numbers[i])):
                if (end != i):
                    start = i
                    end = i + 1
                else:
                    end += 1
                
                if (end - start > max_sequence.get_size()):
                    max_sequence.update(start, end)

        return max_sequence.to_range()
Exemplo n.º 2
0
def test_range_update():
    r = Range()

    r.update(9)
    assert r.upper == 9

    r.update(-1)
    assert r.lower == -1

    r.update(5)
    assert r.lower == -1
    assert r.upper == 9