def test_egg_drop(self): self.assertEqual(egg_drop(1, 2), 2) self.assertEqual(egg_drop(2, 6), 3) self.assertEqual(egg_drop(3, 14), 4)
def test_egg_drop(self): self.assertEqual(egg_drop(1, 2), 2) self.assertEqual(egg_drop(2, 6), 3) self.assertEqual(egg_drop(3, 14), 4)
# If there are no floors, then no trials # needed. OR if there is one floor, one # trial needed. if (k == 1 or k == 0): return k # We need k trials for one egg # and k floors if (n == 1): return k min = sys.maxsize # Consider all droppings from 1st # floor to kth floor and return # the minimum of these values plus 1. for x in range(1, k + 1): res = max(eggDrop(n - 1, x - 1), eggDrop(n, k - x)) if (res < min): min = res return min + 1 from algorithms.dp import egg_drop k = 10 n = 20 ## 4 print(egg_drop(n, k))