Sunday, July 02, 2006

Prison Break Permutation

In an episode of the Fox television show Prison Break, the main character, Michael Scofield, had to punch in an unknown secret code on a 10-key keypad. His whole 5 month plan hinged on his ability to figure out the code in a matter of seconds.

He brought along a container of baby powder that he applied to the keypad. The baby powder adheres to the 4 unique keys that are used in the code. The viewer is made to believe that pressing the keys so often would cause them to retain deposits of oil from the prison guards' fingers (never mind that the guards often wear gloves!).

If you are certain that no number is repeated, then there are 4! = 4x3x2x1 = 24 possible combinations. The flagged buttons were 1, 3, 5 and 8, so he would need to try the following combinations:

1358, 1385, 1538, 1583, 1835, 1853,
3158, 3185, 3518, 3581, 3815, 3851,
5138, 5183, 5318, 5381, 5813, 5831,
8135, 8153, 8315, 8351, 8513, 8531

It took me 75 seconds to type in those 24 combinations. If you were an engineer (like Scofield) and you had to type in these numbers, you would most likely use some algorithm to enter the numbers. This way, you could rifle through the numbers without writing down the already tried combinations. I chose to type in the numbers in ascending order. Instead, Scofield types in these combinations as his first three:
1358, 3581, 8135

It almost looks like he is using some "wrap-around" algorithm for entering the numbers. The only thing is that the third number in the sequence should have been 5813 instead of 8135.

Assuming that he had a method to his combination selection, he should have tried the following combinations (in this order):
1358, 3581, 5813, 8135
1385, 3851, 8513, 5138
1538, 5381, 3815, 8153
1583, 5831, 8315, 3158
1835, 8351, 3518, 5183
1853, 8531, 5318, 3185

This list uses an ascending order for the initial number, then takes the first digit off and appends it to the end. It's not the most intuitive algorithm for entering numbers, but it works.

My point is that I think I can buy the whole baby powder sticking to the keys thing, and maybe he watches the guards with an eagle eye and he was positive that there were exactly 4 numbers in the secret code. The only thing I don't buy is that this guy is a meticulous engineer who executes all his actions in a robot-like manner, yet he punches in the sequence of numbers in a non-sensical fashion.

0 Comments:

Post a Comment

<< Home