Better HN
topnewbestaskshowjobs
Log inSign up

kbgrant

83 karma · joined Jan 23, 2012 (14y ago) · 6 submissions

Submissions

1.

Qualified Small-Business Stock rule helps Silicon Valley workers save millions(nytimes.com ↗)

106 points · by kbgrant · 7y ago · 64 comments

2.

Cactus Kev's Poker Hand Evaluator (2006)(suffe.cool ↗)

2 points · by kbgrant · 9y ago · discuss

3.

The Legacy of GOAL(art-of-optimization.blogspot.com ↗)

4 points · by kbgrant · 12y ago · discuss

4.

Working on the Witness – Semantic Compression(mollyrocket.com ↗)

25 points · by kbgrant · 12y ago · 2 comments

5.

On Mike Acton’s review of OgreNode.cpp(yosoygames.com.ar ↗)

1 points · by kbgrant · 13y ago · discuss

comment 14y ago · link · parent

I was asked this question at a Google interview in 2006. At that time I worked it out mathematically as the author has here. Only afterwards did I realize that it is a simple Dynamic Programming problem.

Let f(y) be the number of drops required with y floors remaining. At a drop from floor x, either the egg breaks and you must test all floors from 1 to x-1, or else the egg does not break and you have reduced to a smaller sub-problem with y-x floors. So the number of drops required is 1 (for the current drop) plus the max of either x-1 or f(y-x). We simply minimize this value over all potential floors x from 1 to y.

Here is a solution in C++: https://gist.github.com/3156157