My Lesson Plan: The Door Lock

Michael Caratenuto:

Personally, I think that this particular image lacks opportunities for inquiry. Perhaps if it was presented with other kinds of door locks leading students to come up with and answer the question, “which is the most secure lock?” [emph. added]

This is exactly right. The latest WCYDWT? installment has provoked the usual litany of Really Interesting Bite-Sized Questions, the sort of prompts that will play great in the Applications & Extensions & Assorted Mindblowers section of your lesson plan but which, on their own, aren’t a lesson plan. Those questions don’t provoke the kind of iterated, increasingly difficult practice that students need for skill development.

Again, this image on its own is insufficient. With some creative modifications, however, it will carry you through permutations. Here is that lesson plan in its broadest strokes.

Start with the image.

Tell them the code is 1 digit long. Tell them the code is 2 digits long. Tell them it’s as long you want it to be. I respected the rule of least power here, which meant that when I took this photo I tried to stay out of the way of your lesson planning. Have them write down all the possible codes for n=1, n=2, n=3, etc. The increasing obnoxiousness of the task will motivate a formula for the general case. That’s arrangements.

Tell them the lock is a 4-digit lock. Now turn on the blue light.

Ask them to list the possible codes. You can iterate this a bunch of times until they have discovered on their own this tool that mathematicians call a factorial.

Remind them it’s a 4-digit lock. Then put up this image. It will be confusing, but only for a second. Ask them to list every possible code.

Iterate this with two and three buttons until they have generalized permutations. Then maybe you iterate the entire thing with another keypad lock.

Then maybe you dip into the comments of the original WCYDWT? post and help yourself to some very-interesting follow-up questions. I recommend Alex’s.

Let me close by saying how shocked I am at how little all of this costs.

[Update: Bruce Schneier has a good follow-up on information leakage. Two photos.]

[Update II: due to the peculiarities of many car door locks punching in “123456” tests both “12345” and “23456.” Consequently, there is a number string 3129 digits long that will test every five-number comination.]

[Update III: more information leakage.]

[Update IV: more information leakage.]

I'm Dan and this is my blog. I'm a former high school math teacher and current head of teaching at Desmos. He / him. More here.


  1. How did you change the color? In your picture editing software, did you just turn the blue channel way high or low? You knowledge of technology is impressive. Did you learn this in your schooling or are you self taught?

    Would this work on all keypad locks? i.e. take a picture and see which ones are used?

    What if multiple codes are used on the same keypad to unlock the door? How much harder would it make this simple trick of narrowing down “used” numbers?

    If I remember correctly, you primarily use Mac, which comes with many of these editing programs included on a new Mac. Is this correct or have you bought a few specific programs? Do you have recommendations for current PC users?

  2. I used Photoshop here. A green adjustment layer maybe. I forget. Nothing terribly complex, but nothing you can do very easily with free software.

    Also, in case it isn’t clear, I added the fingerprints to the image. Pasted them in and added a blue hue adjustment.

  3. I feel completely out of my element here, but when I first saw the original image I thought about the factorial. But it seemed to obvious. So then I started chewing on the number of buttons.

    What if one (or more) button(s) was/were broken? How many possible combinations would there be? How could you determine the buttons that were not working, if the correct code didn’t include one of them? And what if the correct code used a button that wasn’t working, how could you figure out which buttons weren’t working, and how many possible codes there could be?

    Is any of that even mathematically possible?

  4. If you want to make the lesson more involved/challenging you can also introduce the concept of “N choose M” using these fingerprints. This is a little more muddled than I’d like but it’s what I’m thinking right now:

    1) Show an image with 5 fingerprints but tell the students the code is only 3 digits long (the owner accidentally put in an old code first try). Ask the class how many 3 digit codes you can make using only the 5 fingerprint numbers. Students should fairly quickly figure out 5*4*3=60.

    2) Now tell the class that the order of the numbers doesn’t matter, all that matters is that you pick the correct 3 numbers. 5*4*3 counts 1,2,3 and 2,1,3 as different codes so we need to divide 5*4*3 by something. Ask how you should divide out all the different ways to order 3 numbers (maybe “divide” is too leading of a word in these sentences and you can find a better way to phrase the question). If the students understand the factorial from the first half of the lesson they quickly see to divide by 3!.

    3) So there are (5*4*3)/3! ways to choose 3 numbers from 5 choices. Since factorials are all the rage in today’s class let’s see if we can write this just in terms of factorials. 5*4*3 is almost 5!, it’s just missing the *2*1 part. Ideally students realize all you need to do is divide 5! by 2! to get 5*4*3, if they don’t then I’m not sure what the best leading question is.

    4) Finally we get that there are 5!/(3!*2!) = 10 ways to choose 3 numbers from 5 choices when the order doesn’t matter. Ask the class if they can think of any example where you are trying to pick the correct numbers out of some large collection but the order of the numbers doesn’t matter. Maybe a student thinks of the lottery if not you can bring it up.

    5) A parting question: The Wendy’s Super Value menu features 9 items. How many different 3 item meals can you build using just the Super Value menu if no items are repeated in a single meal. See if any student has the answer at the next day’s class, if not you can show them 9!/(3!6!) = 84.

    I’m not sure if this is a class discussion or a worksheet but it’s an idea for something.

  5. @Steven @Alex, here’s the thing: I’m trying to avoid contrived math problems as much as possible while acknowledging that a lot of math problems have to be contrived. (“I have twenty-three coins in my pocket. There are twelve times as many dimes as nickels,” etc. That just kind of bums me out.)

    I like, “What is the combination?” The image practically begs the question.

    But “What if a button was broken?” (Alex’s) seems overly contrived to me, like I’m pushing a tree over the trail just so I can see if my students can climb over it. I’d rather find a more natural place to assess my students’ climbing abilities.

    And “What if order didn’t matter?” (Steven’s) certainly inspires the conept of combinations, but order does matter on a lock. That’s its point. So, again, it isn’t a question this image can reasonably support.

    But! Steven’s final question about a Wendy’s nine-item value menu. Holy cow. Go to Wendy’s. Take a picture of the menu. Project it on the board. Get crazy with combinations. You’re talking about an uncontrived question matched with an image that supports it perfectly. Nice work, team.

  6. @ Dan, @Wendy’s. Don’t forget that the best meal combination is not on the menu at Wendy’s and involves not eating fast food.

  7. I really like this photo. Anything that gets the student to think of the question before I have to ask it is priceless.

    @ Alex, I’m lovin’ the Wendy’s idea. The way I get through Combinations in my class is to first ask my class what they think of when I saw “combination” and almost 80% of the class (at least I’m walkin’ away with one good thing from the paradigm created by being a member of the fast-food generation) say “combo value meals.” After I flash a few pics of an actual value meal that I bought, but with the fries, drink and burger switched around, the students get that order doesn’t matter. That set of 3 or 4 slides alone gets the idea across that combinations aren’t the same as permutations, that nCr on their calculator means that order doesn’t matter, and the only other choice, nPr, means that order does matter.

    With regard to the door lock, I’m a little impatient by nature but I usually give the answer before n=3, for fear that I might be shanked by an impatient kid with a ‘tude and a knack for carving sharp edges. It’s a little too much on the CPM side for me, and I’m always afraid that similar lines of questioning will either cause frustration or will cement in their head the wrong ideas. So, I usually start with n=3 and give them a couple of minutes after the “Awww…are you serious?” looks that I get, and then let them off the hook.

    Also, we can’t necessarily get factorial from this, right? … or am I missing something? (after all, it is way past my bedtime) … Since the combination could be 7777 in a 4-digit code. Help me out here.

    Another awesome lesson. Thanks, Dan! I’m diggin’ the WCYDWT series.

    Also, as usual, the comments add so much more value to an already outstanding post.

  8. …Nevermind my comment on factorials above. Now I see that the comment below the photo was referring to the pic where they only have 4 digits to choose from. A ha…

  9. My thought was the number of possible combinations would be counted, assuming you didn’t know the number of digits, by
    10^1 + 10^2 + 10^3 + 10^4, [up to 10^(num digits)]. Which would explain why knowing the number of digits could significantly decrease the time it takes to crack the code.

  10. Thanks for this!
    I read this post initially from a twitter link but my memory is dreadful so I’m afraid I can’t tell you who brought it to my attention.

    However, I got myself into a conversation about problem solving strategies with my second year class this morning and used this as a trigger for discussion. With the picture on the board I asked simply “what is the combination?”.

    The discussion that ensued was based around what further information was needed to answer the problem because the maths required to state the number of possible solutions is beyond their capabilities for now.

    The class came up with a single questions that they wanted answersed before they would go any further.

    How many numbers are in the code?

    I only told them when they told me that they would normally find the answer to this in the question itself and what strategy they were going to try when they found out. Some sort of ordered list seemed to be the favourite and armed now with the fact there were 3 consecutive numbers in the code they continued.

    Conversation and debate followed about what consectutive could mean, whether or not they could be consecutive in decreasing order and whether 0 could follow 9.

    We got it down to 14 options and everyone agreed they needed more information. The code must be divisible by 2, the first number must be greater than the last and and the sum of the digits is fifteen elimiated all but one and brought us to a conclusion.

    The important lesson today was not the maths – I know that my class can divide by 2, add to 15 and use number order. What was beneficial was to look for the questions that had to be answered because the answers to these normally lie in the text of the question itself if they would just remember to go looking for it!

    A fantastic resource and a lesson that the pupils can direct and to some degree structure themselves with the questions their own questions. I see more potential every time I look at this and also remember that sometimes the simplest resources and ideas can provide the richest tasks.

  11. I love reading the discussions on WCYDWT posts! I’m a bit of a lurker usually, though :) My 8th graders do quite a bit of work with combinations & probability (Georgia curriculum) and I can see using this as a great intro to get them interested in the big ideas, it’s way better than the stupid textbook problems!

    We’re taking a weekend trip to 6 Flags and I’m thinking there’s something I can do with choosing your rides, mapping out your route, etc.

    I also just stumbled upon and thought there are LOTS of possibilities for good questions about data that can be found here.

  12. I actually added that link to the addenda (at the bottom of the post) only a few hours before you added it to the comments. A reader tipped me to it via e-mail. I feel a profound sense of security knowing y’all have me covered for interesting links.