Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Two Eggs Problem
n = int(input())
t = [0] * (n + 1)
def find_min_test(x, t):
if x < 3:
t[x] = x
return x
if t[x]:
return t[x]
t[x] = min(max(i, 1 + find_min_test(x - i, t)) for i in range(1, x + 1))
return t[x]
for i in range(1, n + 1):
find_min_test(i, t)
print(find_min_test(n, t))
for i in range(1, n):
if i * (i + 1) >= 2 * n:
print(i)
break
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment