# How many possible outcomes will there be to my Minecraft lock?

I just built a lock for a door in Minecraft. The user has to pick the correct four colors out of twelve. Order doesn't matter. What is the probability of the user guessing the correct colors?

-
It depends... Can the user press the same color more than once? (From what I understand, I think it's not possible, but Ward answer confused me) – Denilson Sá Jan 29 '11 at 12:50
do you know four colours need to be picked? – Ronan Jan 29 '11 at 15:50
@Denilson no, each color is either "on" or "off." @ronan they should know there are only four colors. – Soup Jan 29 '11 at 20:53
One, me putting a redstone torch in front of said locked door and walking through. – Nick T Jun 24 '11 at 2:13
@Nick Every experienced lock-maker knows to set it up so the door is closed when powered. :P – Maxpm Jun 24 '11 at 6:26

1. You have 4/12 of a chance of picking the first colour right.

2. You have 3/11 of a chance of picking the second colour right from the remaining eleven colours, if you got the first right.

3. You have 2/10 of a chance of picking the third colour right from the remaining ten colours, if you got the former two colours right.

4. You have 1/9 of a chance of picking the fourth colour right from the remaining nine colours, if you got the former three colours right.

Hence, the probability of guessing the combination is: 4/12 × 3/11 × 2/10 × 1/9 = 495-1.

In other words, there are 495 different combinations, of which one is correct.

Obviously, all of this is useless, unless you are working on a exploration mode map. It's much faster to just take a pick and destroy your door.

-
You could some how set it up so if any wall is destroyed TNT or lava is released, lava would be better because if you returned it wouldn't have destroyed the wall like TNT would. – Ronan Jan 30 '11 at 11:44
You don't need to release lava, having it stream down in the first place behind each wall works just as well. If the lava flows from far enough above and goes deep then the player can't easily block it off to pass through. – Sadly Not Jan 30 '11 at 16:52
@Sadly, if the player opens the door with the code, how is he not also killed by the lava? (I have not played Minecraft, just curious) – juan Jun 24 '11 at 15:29
@JuanManuel, I dunno, use some pistons or that business :P it's much easier to block off one column of lava than wait for however many more to be released. – Sadly Not Feb 24 '12 at 17:28

Use the Choose function. You have 12 items, from which you can choose 4 and the order of those chosen 4 does not matter. This means you want to calculate 12 choose 4.

n choose k = n! / (k! * (n - k)!)

So, you have 12!/(4!8!) = 495 different choices, giving you a probability of choosing the one correct answer 1/495 = .00202... = 0.2%

Maths.

-
love the simplicity of this answer... – Soup Jan 29 '11 at 20:55
it isn't the 'choose' function, it's actually the binomial expansion :) – The Communist Duck Jun 24 '11 at 9:12
@The Communist Duck: Same thing! en.wikipedia.org/wiki/Binomial_coefficient "often read as 'n choose k'" – Rawling Jun 24 '11 at 9:52
My bad :P I learnt it as binomial. – The Communist Duck Jun 24 '11 at 10:16