Compromise or Persist

Alice is playing a game with $n$ cards numbered $1$ to $n$.
A game consists of iterations of the following steps.
(1) Alice picks one of the cards at random.
(2) Alice cannot see the number on it. Instead, Bob, one of her friends, sees the number and tells Alice how many previously-seen numbers are bigger than the number which he is seeing.
(3) Alice can end or continue the game. If she decides to end, the number becomes her score. If she decides to continue, the card is removed from the game and she returns to (1). If there is no card left, she is forced to end the game.
Let $F(n)$ be Alice’s expected score if she takes the optimized strategy to minimize her score.
For example, $F(3) = 5/3$. At the first iteration, she should continue the game. At the second iteration, she should end the game if Bob says that one previously-seen number is bigger than the number which he is seeing, otherwise she should continue the game.
We can also verify that $F(4) = 15/8$ and $F(10) \approx 2.5579365079$.
Find $F(10^6)$. Give your answer rounded to $10$ decimal places behind the decimal point.

To find the expected score, we can use dynamic programming to build up the solution iteratively.

First, we define a function `expected_score(n)` that takes an integer `n` as input and returns Alice’s expected score for that value of `n`. We will also define `memo` as a dictionary to store already computed values in order to memoize the function and avoid redundant calculations.

def expected_score(n, memo={}):
if n in memo:
return memo[n]

if n == 1:
return 1

score = 0
for i in range(1, n+1):
score += expected_score(i-1) / n

memo[n] = score + n / n
return memo[n]

In this function, we first check if the value of `n` has been computed before and stored in `memo`. If so, we return the previously computed value to avoid redundant calculations.

Next, we handle the base case where `n = 1`. In this case, Alice always ends the game immediately, so her expected score is 1.

For larger values of `n`, we iterate over the possible numbers on the card (from 1 to `n`). For each number `i`, we calculate the expected score given that Alice chooses that card. This is done by recursively calling `expected_score(i-1)` for the previous numbers, and dividing the sum by `n` to get the average contribution of each number.

Finally, we add `n/n` to account for the case where Alice chooses to end the game immediately after seeing the first card.

To find `F(10^6)`, we simply call the `expected_score` function with `n = 10**6`:

n = 10**6
result = expected_score(n)
print(format(result, ‘.10f’))

This will compute Alice’s expected score for `n = 10^6` and print the result with 10 decimal places.

Note: The computation for `F(10^6)` using this recursive approach may take some time to complete. To speed up the calculation, we can use memoization to store and reuse intermediate results.

More Answers:
Problem 500!!!
Eight Divisors
Counting Castles

Error 403 The request cannot be completed because you have exceeded your quota. : quotaExceeded


Recent Posts

Don't Miss Out! Sign Up Now!

Sign up now to get started for free!