The Door Lock – a lesson sketch
Apr 28th, 2009 by Nick
I’ll take the bait, and put out a math lesson plan. I suppose its better late than never, though I may have missed out on the discussion for this one.
Title of the Song: Iteration, Efficiency (or lack-thereof) and Counting Combinations, when it really maters.
Objectives:
Students are able to apply iteration (that they discover a way to apply the ‘ol brute force – test everything – method).
Students write an iterative algorithm to crack a code.
For advanced students: design a program to demonstrate the process of cracking a code of up to 6 characters that 1 asks for a code, then cracks it (iteratively), and finally outputs the number of attempts to crack the code.
I suppose you could start there.
Motivation: Teacher walks into class and asks kids if they’ve ever forgotten something unforgettable. Like their uncle’s brother’s name during a family gathering or their underwear on a two week camping trip, you know something you would really miss. Have a few kids chime in, and then ask, what if the thing you forgot in your one door home was…
this? [up goes the picture onto the projector], “the combination”
Thoughts?
Student Responses and further motivation.
1. Students might suggest that they would call the locksmith, or go around back. Response: If I had a lock like this on my door, do you think I would have left a window open in the back? Clearly I think about my security… too much? To the locksmith objection, what’s the locksmith going to have to do? If the lock can’t be picked?
2. Someone suggests taking a guess. Sufficient motivation requires that the combination could be anything, not just a vague memory (though this presents opportunities later at the end of the problem for discussing how restrictions on the randomness greatly reduce the time needed for an efficient algorithm to crack the code.
What exactly would you do and how long would it take? To motivate this part of the activity, the teacher should place a secret multi-digit numerical code into a letter and stick it next to the board. Something like “8264190″. The goal is for students to explain the specific details of how you would guess the possible combinations. Remember that 002 and 02 and 2 are all different combinations1.
Optionals. (1) Spend time designing a clearly written algorithm for breaking the code. Systematically, how would you break this code? Write it out. (2) Make the leap from prose to calculator programming. Which I’ll describe below.
Making the leap from a prose-like procedure to TI-BASIC syntax2: Display a simple program like
rompt A
:if A<10:A+1->A
isp A
What will this program do?
And another one. Have students evaluate the code for sample entries A = 17 and B = 25, etc. until they understand the way the code works.
isp "CODE"
rompt A
isp "GUESS"
rompt B
:while A<100:
:if A=B:Then
:GoTo 1
:Else
:A+1->A
:End:End
:Lbl 1 :if A=B: Disp "A matches B"
ause
isp "A is ",A,"B is ",B
Ask: can anyone write code to break the code faster?
Reflection. I think this activity would be engaging for students who could write some code to make it faster – by allowing for lower and upper limits of the guesses. Presently the program views 007 the same as 7, which is a flaw, but in order to fix the place value problems you’d have to go a bit more sophisticated and I don’t know where to go with that on the TI. The more I think about it, the cooler I think it would be to go off and by a few combination locks, tag them, write down the combination, and pass them out to groups, and have the kids actually break the combination and record how long it took. This could be a multi-night HW assignment. Kid A could take the lock for the first night, Kid B the next, C the next, and the first team to break their combo wins a prize.
- Note to the teacher: If 01, 001, and 0001, etc. are all to be considered then instead of having 10^4 possible combinations, a 4-digit answer would potentially require 10^1 + 10^2 + 10^3 + 10^4 – 1 (is that right?) possible attempts to be cracked.If the number of digits in the code is known, then there are 10^(number of digits)-1 unique guesses. ↩
- I have never succeeded at doing this with a class. It always turns into me telling them what to type and them typing it and trying not to make a mistake. ↩



Hi
Nick
I read you are article its is very nice i like these type of article and it very useful.
thank u..