All about flooble | fun stuff | Get a free chatterbox | Free JavaScript | Avatars    
perplexus dot info

Home > Numbers
Guessing Game (Posted on 2014-05-16) Difficulty: 3 of 5
We decide to play the following game: An integer N will be randomly selected from the interval 0 - 100, inclusive. You try to guess N. After each guess, I tell you whether N is higher or lower than your guess.

If you successfully guess the integer, you win N dollars. Each guess costs you K dollars.

For each of the variants (a) and (b) below, what is the maximum value of K for which you'd be willing to play this game? Which strategy would you use to try to maximize your winnings in the long run?

(a) Once you start a round, you must continue until you guess N exactly.

(b) You may stop playing a round if you determine that N is too small to keep paying more money to guess N exactly. The money you've already spent on guesses is lost, but you may then start a new round with a new N.

No Solution Yet Submitted by tomarken    
Rating: 5.0000 (1 votes)

Comments: ( Back to comment list | You must be logged in to post comments.)
Solution Repaired VB program agrees with Steve's answer to part b | Comment 11 of 19 |
DefDbl A-Z
Dim crlf$
Dim guess(100, 100)
Dim expVal(100, 100), k

Function mform$(x, t$)
  a$ = Format$(x, t$)
  If Len(a$) < Len(t$) Then a$ = Space$(Len(t$) - Len(a$)) & a$
  mform$ = a$
End Function

Private Sub Form_Load()
 Text1.Text = ""
 crlf$ = Chr(13) + Chr(10)
 Form1.Visible = True
 DoEvents
 For k = 11 To 12 Step 0.01
   For span = 1 To 101
    For start = 0 To 100
      fin = start + span - 1
      If fin <= 100 Then
        If span = 1 Then
         expVal(start, fin) = start - k
         guess(start, fin) = start
        Else
         bestev = -999999
         For g = start To start + span - 1
             ev = g / span  ' hit it this guess
             If g > start Then ev = ev + ((g - start) / span) * expVal(start, g - 1)
             If g < start + span - 1 Then ev = ev + (((start + span - 1) - g) / span) * expVal(g + 1, start + span - 1)
             ev = ev - k
             If ev > bestev Then
               bestev = ev: bestg = g
             End If
         Next g
         If bestev > 0 Then
            guess(start, fin) = bestg
            expVal(start, fin) = bestev
         Else
            guess(start, fin) = -1
            expVal(start, fin) = 0
         End If
        End If
      
      End If
    Next start
   Next span
   Text1.Text = Text1.Text & mform(k, "###.00  ") & mform(expVal(0, 100), "##0.00000") & mform(guess(0, 100), "##0") & crlf
   DoEvents
 Next k
End Sub
		     best
    init
   K    exp. gain    guess 
  4.00   27.80198     48
  5.00   22.87129     45
  6.00   18.33663     37
  7.00   14.30693     42
  8.00   10.63366     48
  9.00    7.31683     54
 10.00    4.35644     60
 11.00    1.75248     66
 12.00    0.00000     -1
 13.00    0.00000     -1
 14.00    0.00000     -1
 15.00    0.00000     -1
 16.00    0.00000     -1
 17.00    0.00000     -1
 18.00    0.00000     -1
 19.00    0.00000     -1
 20.00    0.00000     -1
 21.00    0.00000     -1
 22.00    0.00000     -1
 
where -1 indicates not to bet, which is the only reason the expected gain is zero rather than negative.

Finer distinctions:

 11.00    1.75248 66
 11.01    1.72851 67
 11.02    1.70455 67
 11.03    1.68059 67
 11.04    1.65663 67
 11.05    1.63267 67
 11.06    1.60871 67
 11.07    1.58475 67
 11.08    1.56079 67
 11.09    1.53683 67
 11.10    1.51287 67
 11.11    1.48891 67
 11.12    1.46495 67
 11.13    1.44099 67
 11.14    1.41703 67
 11.15    1.39307 67
 11.16    1.36911 67
 11.17    1.34535 68
 11.18    1.32198 68
 11.19    1.29861 68
 11.20    1.27525 68
 11.21    1.25188 68
 11.22    1.22851 68
 11.23    1.20515 68
 11.24    1.18178 68
 11.25    1.15842 68
 11.26    1.13505 68
 11.27    1.11168 68
 11.28    1.08832 68
 11.29    1.06495 68
 11.30    1.04158 68
 11.31    1.01822 68
 11.32    0.99485 68
 11.33    0.97149 68
 11.34    0.94851 69
 11.35    0.92574 69
 11.36    0.90297 69
 11.37    0.88020 69
 11.38    0.85743 69
 11.39    0.83465 69
 11.40    0.81188 69
 11.41    0.78911 69
 11.42    0.76634 69
 11.43    0.74356 69
 11.44    0.72079 69
 11.45    0.69802 69
 11.46    0.67525 69
 11.47    0.65248 69
 11.48    0.62970 69
 11.49    0.60693 69
 11.50    0.58416 69
 11.51    0.56139 69
 11.52    0.53861 69
 11.53    0.51584 69
 11.54    0.49307 69
 11.55    0.47030 69
 11.56    0.44752 69
 11.57    0.42475 69
 11.58    0.40198 69
 11.59    0.37921 69
 11.60    0.35644 69
 11.61    0.33366 69
 11.62    0.31089 69
 11.63    0.28812 69
 11.64    0.26535 69
 11.65    0.24257 69
 11.66    0.21980 69
 11.67    0.19703 69
 11.68    0.17426 69
 11.69    0.15149 69
 11.70    0.12871 69
 11.71    0.10594 69
 11.72    0.08317 69
 11.73    0.06040 69
 11.74    0.03762 69
 11.75    0.01485 69
 11.76    0.00000 -1
 11.77    0.00000 -1
 11.78    0.00000 -1
 11.79    0.00000 -1
 11.80    0.00000 -1
 11.81    0.00000 -1
 11.82    0.00000 -1
 11.83    0.00000 -1
 11.84    0.00000 -1
 11.85    0.00000 -1
 11.86    0.00000 -1
 11.87    0.00000 -1
 11.88    0.00000 -1
 11.89    0.00000 -1
 11.90    0.00000 -1
 11.91    0.00000 -1
 11.92    0.00000 -1
 11.93    0.00000 -1
 11.94    0.00000 -1
 11.95    0.00000 -1
 11.96    0.00000 -1
 11.97    0.00000 -1
 11.98    0.00000 -1
 11.99    0.00000 -1
 12.00    0.00000 -1

  Posted by Charlie on 2014-05-18 12:06:44
Please log in:
Login:
Password:
Remember me:
Sign up! | Forgot password


Search:
Search body:
Forums (0)
Newest Problems
Random Problem
FAQ | About This Site
Site Statistics
New Comments (0)
Unsolved Problems
Top Rated Problems
This month's top
Most Commented On

Chatterbox:
Copyright © 2002 - 2024 by Animus Pactum Consulting. All rights reserved. Privacy Information