Hacker News new | ask | show | jobs
by csells 1787 days ago
It depends on your definition of optimal. If you optimize for time, then pressing each button one at a time until a Coke comes out. Plus it doesn't take any brain cells so I can get back to coding quicker. : )
1 comments

You can also optimize for

- The highest likelihood of getting your choice with a single pick

- The least amount of money spent to guarantee getting your choice

If you take as given, "none of them are correct," I think both of those optimisations still start with pressing Pepsi. It is either Coke or random, so you have about a 75% chance of getting what you want on the first press.
If none of them are correct, then

- pepsi is coke or random

- coke is pepsi or random

- random is coke or pepsi

If you want Coke and you start with Pepsi, you'll get back Coke (1/2 + 1/2x1/2) or Pepsi (1/2x1/2). However, you could pick it and get back Pepsi 10 times in a row.

If you start by picking Random, you get back Coke (1/2) or Pepsi (1/2). If you get back Pepsi, you know

1. Random = Pepsi 2. Coke = Random (since it can no longer be Pepsi, since Random is) 3. Pepsi = Coke

So, you get back Coke on your first attempt (1/2), or you get back Coke on your second attempt (1/1).

So picking random first, then the correct one, optimizes for lowest upper bound on the number of choices to get what you want. Which is _actually_ what I meant by "The least amount of money spent to guarantee getting your choice", but didn't actually express correctly.

> If you want Coke and you start with Pepsi, you'll get back Coke (1/2 + 1/2x1/2) or Pepsi (1/2x1/2). However, you could pick it and get back Pepsi 10 times in a row.

Why would you push it ten times in a row? If you get a Pepsi from it on your first press, you now know:

- The button labeled Pepsi is actually Random (it can't be the actual Pepsi button, since none of the labels are correct, and it's also not the Coke button)

- Therefore, the button labeled Coke is actually Pepsi (it can't be Coke by rule, and it's also not Random since we know where Random is now)

- Therefore, the button labeled Pepsi is actually Coke (elimination)

So the max is still 2 steps, but you have 75% chance of getting a Coke on the first try instead of just 50% chance. Same lower bounds, but better expected value.

If you hit the Pepsi button and get Pepsi, you know it's random, so the random button has to be Coke (and Coke gives Pepsi). So picking the Pepsi button first still works in two tries - you either get a Coke all the time, get it randomly on the first try, or figure out which button gets you Coke.
Whoops, good point.
At a quick glance, everyone in this thread seems to be assuming 'random' gives you Coke or Pepsi with equal probability ….
Regardless of the probability distribution of the random button, it does not change the optimal strategy. By pressing the Pepsi button, you are either going to get Coke (you "win") or Pepsi (so you know the button is random and you "win" by pressing random on the next go which you now know is Coke).
> Regardless of the probability distribution of the random button, it does not change the optimal strategy.

I agree, and didn't mean to suggest otherwise. I was just referring to the specific probability computations being made.