human
I found an interesting problem on https://leetcode.com/problems/super-egg-drop/:
You are given K eggs, and you have access to a building with N floors from 1 to N. 
Each egg is identical in function, and if an egg breaks, you cannot drop it again.
You know that there exists a floor F with 0 <= F <= N such that any egg dropped at a floor higher than F will break, and any egg dropped at or below floor F will not break.
Each move, you may take an egg (if you have an unbroken one) and drop it from any floor X (with 1 <= X <= N). 
Your goal is to know with certainty what the value of F is.
What is the minimum number of moves that you need to know with certainty what F is, regardless of the initial value of F?
 


Example 1:
Input: K = 1, N = 2
Output: 2
Explanation: 
Drop the egg from floor 1.  If it breaks, we know with certainty that F = 0.
Otherwise, drop the egg from floor 2.  If it breaks, we know with certainty that F = 1.
If it didn't break, then we know with certainty F = 2.
Hence, we needed 2 moves in the worst case to know what F is with certainty.

Example 2:
Input: K = 2, N = 6
Output: 3

Example 3:
Input: K = 3, N = 14
Output: 4

 
Note:

1 <= K <= 100
1 <= N <= 10000

I tried it in Python, but could not do it. Can you solve it?

 ... Give me a the minimum number of moves that you need to know with certainty what F is, regardless of the initial value of F?
assistant
#Here is the minimum number of moves that you need to know with certainty what F is, regardless of the initial value of F.

#class Solution:
#    def superEggDrop(self, K: int, N: int) -> int:
#        def solve(e,f,dp):
#            if f==0:
#                return f
#            elif e==1:
#                return f
#         
#            if dp[e][f]!=-1:
#                return dp[e][f]
#            l,h=1,f
#            while l+1<h:
#                x=(l+h)//2
#                if dp[e][f-x]!=-1:
#                    f1=dp[e][f-x]
#                else:
#                    f1=solve(e,f-x,dp)
#                if dp[e-1][x-1]!=-1:
#                    f2=dp[e-1][x-1]
#                else:
#                    f2=solve(e-1,x-1,dp)
#                if f1<f2:
#                    l=x
#                elif f2>f1:
#                    h=x
#                else:
#                    l=h=x
#            
#            ans=1+min(max(solve(e,f-x,dp),solve(e,x-1,dp)) for x in range(l,h+1))
#            dp[e][f]=ans    
#            return dp[e][f]
#        dp=[[-1]*(N+1) for i in range(K+1)]
#        return solve(K,N,dp)
class Solution(object):
    def superEggDrop(self, K, N):
        memo = {}
        def dp(k, n):
            if (k, n) not in memo:
                if n == 0:
                    ans = 0
                elif k == 1:
                    ans = n
                else:
                    lo, hi = 1, n
                    # keep a gap of 2 X values to manually check later
                    while lo + 1 < hi:
                        x = (lo + hi) // 2
                        t1 = dp(k-1, x-1)
                        t2 = dp(k, n-x)

                        if t1 < t2:
                            lo = x
                        elif t1 > t2:
                            hi = x
                        else:
                            lo = hi = x
                    ans=1000000
                    for x in range(lo, hi+1):
                            temp=1+max(dp(k-1, x-1), dp(k, n-x))
                            if ans>temp:
                                ans=temp
                    
                    

               ...