# Finding a random number in a randomly assigned number in boxes [duplicate]

In a closed room, paper slips labelled $1$ to $100$ are randomly put into boxes also labeled $1$ to $100$. You win a big prize if you can locate a given number (from $1$ to $100$) by opening no more than $50$ boxes. As stated, your odds of winning the prize are, clearly, $50$%. Now, suppose you have an accomplice that can go into the room just before the boxes are being sealed and secretly switch the content of two boxes (due to time constraint, this all he can do). By how much your odds of winning can be improved?

## marked as duplicate by Ivo Beckers, DrunkWolf, Carl Löndahl, manshu, GamowJan 20 '16 at 12:51

• I think I remembered this one before but can't find any duplicate question – Ivo Beckers Jan 20 '16 at 11:49
• My first reaction would be to say that the odds do not improve, as viewing yourself and your accomplice as two different independent systems would mean that he doesn't help you in any way as his actions are random too. But knowing this forum there's probably a catch, or have you forgotten to mention that the accomplice would willfully try to put the right numbers in the right boxes? In that case, it would be an interesting problem – nine9 Jan 20 '16 at 11:53

100%

Open the box with the same number as your given number. See what number is in there and go to that box number, and repeat. Eventually it must loop back to the first number. Without accomplice this loop could be all 100 boxes.

break the greatest loop there is in two smaller loops half the size. That way there won't be any loops larger than 50 and you always get your number

• I'm not sure the accomplice knows what's in each box. If so, maybe OP should clarify. – Masclins Jan 20 '16 at 12:01
• @AlbertMasclans of course the accomplice knows this, otherwise there is no point in switching – Ivo Beckers Jan 20 '16 at 12:10

firstly, you and your accomplice do not know what number is going to be given. so he/she can open a box, let say it is box #1 and the number is 10 in the box. then he can open another box which is the same number in the previous box, for this case, box #10. and check the number in the box and switch it with 1 whatever (s)he gets, let say he got 50. so u guarantee that at least one of the number and box number will surely be the match and it is not the one in the box #1.

firstly the chance of getting 1 from #1 is 1/100 for your accomplice, and he will not switch then, not getting 1 and gettin one from the box #10 is 99/100*1/99 = again 1/100. and not getting 1 from both then is 98/100 as a result.

so ur chance of getting one from number one is 2/100, and u know that at least one of the box has the same number as box and open the given number then. the chance of given number is different than your switched box is 99/100. and the chance of getting the same box as u switch is 1/99. so another 1/100 from here added.

as a result, take number 1, then take the number given, then take box as the same number in box#1 (u know that box has different number for sure), take always the box with the number in the previous box always not to encounter the box and the number different.

so 1-98/100*98/99*97/98.... (50 times) = the new outcome ( edited: it will be much more complicated since i changed the algorithm as taking box according to previous nnumber in the previous box)

typing on the phone, so cant calculate :(