def search_min(n, lim): high = n while fill(high, n) < lim: high *= 2 low = high/2 while True: n1 = (high+low)/2 v = fill(n1, n) if v < lim: low = n1+1 elif v > lim: high = n1-1 else: return n1 n2 = (high+low)/2 if n1 == n2: if high > low: return high return low
def test1(self): self.assertEqual(880711, fill(56, 10), "p115 known condition") self.assertEqual(1148904, fill(57, 10), "p115 known condition")