Results 1 to 13 of 13
  1. #1
    Super Moderator BATcher's Avatar
    Join Date
    Feb 2008
    Location
    A cultural area in SW England
    Posts
    3,413
    Thanks
    33
    Thanked 195 Times in 175 Posts

    Ways of not cracking a lock

    Push-button-Lock.png

    A fairly-simple push-button mechanical lock is opened by pressing-in 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:
    1. when the order of pressing of the buttons is important (e.g. must be “1, 2, 3, 4”), or
    2. 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

    Time prevents everything happening all at once...

  2. #2
    Bronze Lounger
    Join Date
    Jan 2001
    Location
    La Jolla, CA
    Posts
    1,468
    Thanks
    30
    Thanked 61 Times in 57 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 miss-named. It should be called a permutation lock because order does matter. If 1-2-3-4 opens the lock, 4-3-2-1 does not. That's a permutation.

  3. #3
    Super Moderator BATcher's Avatar
    Join Date
    Feb 2008
    Location
    A cultural area in SW England
    Posts
    3,413
    Thanks
    33
    Thanked 195 Times in 175 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

    Time prevents everything happening all at once...

  4. #4
    Bronze Lounger
    Join Date
    Jan 2001
    Location
    La Jolla, CA
    Posts
    1,468
    Thanks
    30
    Thanked 61 Times in 57 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.

  5. #5
    Super Moderator BATcher's Avatar
    Join Date
    Feb 2008
    Location
    A cultural area in SW England
    Posts
    3,413
    Thanks
    33
    Thanked 195 Times in 175 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

    Time prevents everything happening all at once...

  6. #6
    Bronze Lounger
    Join Date
    Jan 2001
    Location
    La Jolla, CA
    Posts
    1,468
    Thanks
    30
    Thanked 61 Times in 57 Posts
    That's combinations of 10 things 4 at a time which is only 210.

  7. #7
    Gold Lounger Maudibe's Avatar
    Join Date
    Aug 2010
    Location
    Pa, USA
    Posts
    2,629
    Thanks
    114
    Thanked 644 Times in 588 Posts
    For Question #1, here is how I found the answer:

  8. #8
    Super Moderator BATcher's Avatar
    Join Date
    Feb 2008
    Location
    A cultural area in SW England
    Posts
    3,413
    Thanks
    33
    Thanked 195 Times in 175 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 eight-button pressing problem?
    BATcher

    Time prevents everything happening all at once...

  9. #9
    Bronze Lounger
    Join Date
    Jan 2001
    Location
    La Jolla, CA
    Posts
    1,468
    Thanks
    30
    Thanked 61 Times in 57 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! / (n-r)! times 1/r! which is n! / (r!)(n-r)!

    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+r-1)! / (r!)(n-1)! PHEW. I think I'll just go get a bowl of ice cream right now.

  10. #10
    WS Lounge VIP Browni's Avatar
    Join Date
    Dec 2009
    Location
    Rochdale, UK
    Posts
    1,650
    Thanks
    38
    Thanked 160 Times in 138 Posts
    Factorials always give me headaches

    EG the odds in winning the lottery in the UK are 49! / (49-6)!

    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

  11. #11
    Bronze Lounger
    Join Date
    Jan 2001
    Location
    La Jolla, CA
    Posts
    1,468
    Thanks
    30
    Thanked 61 Times in 57 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! * (49-6)! ] 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; 2015-04-03 at 17:36.

  12. #12
    Gold Lounger Maudibe's Avatar
    Join Date
    Aug 2010
    Location
    Pa, USA
    Posts
    2,629
    Thanks
    114
    Thanked 644 Times in 588 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

  13. #13
    Super Moderator BATcher's Avatar
    Join Date
    Feb 2008
    Location
    A cultural area in SW England
    Posts
    3,413
    Thanks
    33
    Thanked 195 Times in 175 Posts
    Quote Originally Posted by kweaver View Post
    I think there's a better chance of being struck by lightning than winning the lottery most places.
    But, as I heard once "you have to be in it to win it."
    Conversely, a statistician also said that:
    "The odds of someone winning the lottery are almost identical, whether you buy a ticket or not."!
    BATcher

    Time prevents everything happening all at once...

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •