Results 1 to 13 of 13
Thread: Ways of not cracking a lock

20150402, 09:44 #1
 Join Date
 Feb 2008
 Location
 A cultural area in SW England
 Posts
 3,438
 Thanks
 33
 Thanked 196 Times in 176 Posts
Ways of not cracking a lock
PushbuttonLock.png
A fairlysimple pushbutton mechanical lock is opened by pressingin the correct sequence of buttons (numbered from 0 to 9) and then turning a lever.
The number of buttons in the coding sequence is usually set to from three to eight, but for the initial part of this problem consider that the correct four buttons require to be pressed to cause the lock to open.
Once the button corresponding to a number is pressed, it stays in and does not release until the lock is opened (or the Clear button is pressed). So the sequence “1, 2, 3, 4” would be an acceptable setting, but not “1, 2, 3, 3” (since the 3 button cannot be pressed twice).
When the code is set, there is (obviously!) only one permutation* of the four numbers which will enable the lock to be opened.
The question is: how many possible ‘button press’ permutations* are there:
 when the order of pressing of the buttons is important (e.g. must be “1, 2, 3, 4”), or
 when the order of pressing the buttons does not matter (i.e. 1, 2, 3 and 4 may be pressed in any order, such as “4, 2, 1, 3” or “3, 1, 2, 4”)?
Please show how you have obtained these two answers!
If you feel enthusiastic, it would be interesting to generalise (both parts of) the question for the required pressing of three buttons, of five buttons, six buttons, seven buttons and eight buttons.

* I may mean ‘combination’ rather than ‘permutation’ – but it’s been a _l_o_n_g_ time…!BATcher
"The trouble with quotes on the internet is that you can never know if they are genuine."
Abraham Lincoln

20150402, 10:36 #2
 Join Date
 Jan 2001
 Location
 La Jolla, CA
 Posts
 1,480
 Thanks
 32
 Thanked 63 Times in 59 Posts
When you say order matters, do you mean the numbers must be increasing as in 1, 2, 3, 4? Can one push the buttons simultaneously or only 1 at a time? Otherwise, I think both of these are the same
If the order is NOT significant, it's combinations; if the order is significant, it's permutations. An old fashion "combination" lock is really missnamed. It should be called a permutation lock because order does matter. If 1234 opens the lock, 4321 does not. That's a permutation.

20150402, 12:52 #3
 Join Date
 Feb 2008
 Location
 A cultural area in SW England
 Posts
 3,438
 Thanks
 33
 Thanked 196 Times in 176 Posts
To be honest, I don't know if you can press two or more numbers simultaneously  there is probably an interlock to prevent this. (Let's say there is, for the purposes of the question!)
No, I meant that the order of pressing matters in question 1, such that the answer "1, 2, 3, 4" differs from "4, 1, 2, 3" (and from the remaining 22 of the 24 permutations of four numbers  the total being 4!, 4 factorial, if I remember correctly).
Does that make it more precise?BATcher
"The trouble with quotes on the internet is that you can never know if they are genuine."
Abraham Lincoln

20150402, 14:31 #4
 Join Date
 Jan 2001
 Location
 La Jolla, CA
 Posts
 1,480
 Thanks
 32
 Thanked 63 Times in 59 Posts
I think there are 10 options for the first press; 9 for the second; 8 for the 3rd and 7 for the 4th making the product = 5040 ways.

20150402, 15:33 #5
 Join Date
 Feb 2008
 Location
 A cultural area in SW England
 Posts
 3,438
 Thanks
 33
 Thanked 196 Times in 176 Posts
That answers the question for when the order in which the buttons are pressed matters*  how about when the 'pressing order' is irrelevant?
* to my mind, at least!BATcher
"The trouble with quotes on the internet is that you can never know if they are genuine."
Abraham Lincoln

20150402, 16:26 #6
 Join Date
 Jan 2001
 Location
 La Jolla, CA
 Posts
 1,480
 Thanks
 32
 Thanked 63 Times in 59 Posts
That's combinations of 10 things 4 at a time which is only 210.

20150402, 21:14 #7
 Join Date
 Aug 2010
 Location
 Pa, USA
 Posts
 2,685
 Thanks
 121
 Thanked 667 Times in 608 Posts
For Question #1, here is how I found the answer:

20150403, 04:32 #8
 Join Date
 Feb 2008
 Location
 A cultural area in SW England
 Posts
 3,438
 Thanks
 33
 Thanked 196 Times in 176 Posts
Gosh  a program to solve the problem! Well done!
(The BATch file solution would be almost identical in structure...!)
Does anyone want to have a go at the three, five, six, seven, and eightbutton pressing problem?BATcher
"The trouble with quotes on the internet is that you can never know if they are genuine."
Abraham Lincoln

20150403, 11:19 #9
 Join Date
 Jan 2001
 Location
 La Jolla, CA
 Posts
 1,480
 Thanks
 32
 Thanked 63 Times in 59 Posts
These are all the same theory. If order matters (permutations) or if order does not matter. Lotteries are combinations without repetition, for example. If you have 3 things (e.g., label them "1", "2", and "3") when order matters there are 6 options (1,2,3; 1,3,2; 2,1,3; 2,3,1; 3,2,1; and, 3,2,1) but if order doesn't matter, there's only 1 option: 1,2,3 So, permutations have 6 times as many possibilities. Permutations for 3 things is 3!. If there were 4, it's 4! . Without concern for order, you have to lower the cases by how many objects could be in order. Therefore, n! / (nr)! times 1/r! which is n! / (r!)(nr)!
Combinations WITH repetition is another thing entirely.
If you're going to have a bowl of ice cream and you have, say, 5 flavors from which to choose 3 but you can also double or triple up in your choices (e.g., 2 chocolate a 1 vanilla) that's n=5 things to choose from and you select 3. Order doesn't matter AND you can repeat flavors. That's: (n+r1)! / (r!)(n1)! PHEW. I think I'll just go get a bowl of ice cream right now.

20150403, 15:46 #10
 Join Date
 Dec 2009
 Location
 Rochdale, UK
 Posts
 1,693
 Thanks
 38
 Thanked 170 Times in 148 Posts
Factorials always give me headaches
EG the odds in winning the lottery in the UK are 49! / (496)!
That's 6 random numbers from 49
You can obviously replace the 49 & 6 with any numbers of your choice, from the OP that would be 10 & 4 which when worked out equals @kweavers first post

20150403, 17:28 #11
 Join Date
 Jan 2001
 Location
 La Jolla, CA
 Posts
 1,480
 Thanks
 32
 Thanked 63 Times in 59 Posts
I think there's a better chance of being struck by lightening than winning the lottery most places.
But, as I heard once "you have to be in it to win it."
Since the lottery doesn't care about order, the formula is: 49! / [6! * (496)! ] which amounts to 1 in 13,983,816.
The "nice" think about factorials in fractions is that the heavy work is cancelled:
49! / 43! ends up being 49x48x47x46x45x44x43! / 43! leaving you with (only) the product of 6 numbers.Last edited by kweaver; 20150403 at 17:36.

20150403, 23:29 #12
 Join Date
 Aug 2010
 Location
 Pa, USA
 Posts
 2,685
 Thanks
 121
 Thanked 667 Times in 608 Posts
Well the furthest I could go was to 6 because I ran out of rows on the spreadsheet. The answer for 6 is
Kw,
I think more appropriate odds would be a tornado going through a junk yard and assembling an aircraft carrier

20150404, 03:55 #13