Last active
August 29, 2015 13:59
-
-
Save mrjohannchang/11000240 to your computer and use it in GitHub Desktop.
Two Eggs Problem
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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