techInterview
Answers to technical interview questions - accepting donations for dogs

 
home
faq
reading
feedback
discuss
archive
fogcreek
bug tracking
pets in ny
petfinder



*new* techInterview bible


thank your brain
save a dog's life




 

Solved by Thomas W. Millett

solution: oil mogul

This problem amounts to properly defining the expected value of the well to you.

The following equation does it:

(1%) * [(1.5 - 1)] +

(1%) * [(3 - 2) + (1.50 - 2)] +

(1%) * [(4.5 - 3) + (3 - 3) + (1.5 - 3)] +

. . .

(1%) * [(150-100) + ... + (3-100) + (1.5-100)]

Each line represents your expected value from a bid of 1$, 2$, ..., 100$, respectively.

eg, consider line 2 above. if you bid $2...

With 98% probability you won't win the contract, so your profit is 0. With 1% probability, you will win something worth (150%*1) = 1.5, for which you paid 2$ With 1% probability, you will something worth worth (150%*2) = 3, for which you paid 2$

So, your goal is to maximize the following function of x, where x is your bid.

f(x) = 1% * Sum_{i = 1 to floor(x)}{ x - 1.5*i }

There's no benefit to non-integer bets, so re-write the maximization function as :

ARGMAX(k) {1% * Sum_{i = 1 to k}{1.5*i - k}}

(=) ARGMAX(k) {Sum_{i=1 to k}{1.5*i - k}} /* 1% isn't a function of k or i, so toss it */

(=) ARGMAX(k) {Sum_{i=1 to k}{1.5*i} - Sum_{i=1 to k}{k}} /* Split the summation */

(=) ARGMAX(k) {(0.75)(K)(K+1) - K^2 }} /* Closed form for summations */

(=) ARGMAX(k) {(0.75)(k)-(0.25)(K^2)}} /* Algebra */

And that function is maximized at k = 1 and k = 2.

When choosing b/w $1 and $2, you should bid $1 because of time-value, reinvestment risk, etc, of the extra dollar.

(ie, if you don't have to spend the extra $$ now, don't)

That's my solution.


 



home | software development | bug tracking software | archive

[general software discussion] [dogs new york city] [Software Quality]