Behind the Bars: A Short Lesson on Codes

prepared for the NCTM Regional Conference : Springfield, MA 2000
by
Jeffrey P. Hoyle
Dartmouth Middle School
Dartmouth, MA 02747
http://accordingtohoyle.cjb.net
jhoyle1@attbi.com








Behind the Bars: A Short Lesson on Codes

prepared for the NCTM Springfield Regional by Mr. Jeffrey P. Hoyle, Dartmouth Middle School, Dartmouth, MA 02747


Braille, semaphore, morse code, ISBN, zip codes. Codes are all around us. They are used to encode and decode messages. The Spartans used a “skytale” tapered stick with wrap around messages. Julius Caesar used a simple shifting letter substitution system. In World War II, the Germans used the Enigma wheel to encode and decode messages. Today codes are still used to detect and sometimes correct errors. There are Postal Bar Codes and the Universal Product Code. The Internet uses the products of two primes to encode credit card numbers. Movies like Mercury Rising, Sneakers and Contact had plots based on breaking codes. In this short lesson we will look at and break a few codes and hopefully give you a better idea about this practical use of mathematics and problem solving.

1. A message was encoded by replacing each letter with the letter that comes before it in the alphabet. What does the following message say ?

BZM XNT RSTCDMSR CDBNCD SGHR ? VGZS ZANTS “Z” ?




2. A student assigned the numbers 1 through 26 to the letters A-Z in increasing order. Can you decode the following message ?


5 1 19 25 3 15 4 5



14 9 3 5 23 15 18 11



3. Another student assigned numbers to the letters as follows: A--1, B--4. C--7, D--10 etc. Can you determine the pattern and use that to decode the following message ?

67 13 ‘ 34 34 55 43 34 64 13 55 43 37 13 4 1 52 7 43 û10 13 55
55 43 43 40






4. How would you decode the following message assuming it was generated using the same code ?

19 43 10 1 52 58 37 43 61 58 22


5. In transposition ciphers the letters have been boxed and shuffled. For example “WE HAVE RUN OUT OF MILK” could be written in a 6X3 grid as:


W E H A V E
R U N O U T
O F M I L K

Reading down the columns gives us
W R O E U F H N M A O I V U L E T K

Try to decipher this message:

CETTAEHONTENYMGIOEAGUAMHMTET



6.. But what if the code is a bit more difficult to figure out. For example:
















Behind the Bars: A Short Lesson on Codes
prepared for the NCTM Springfield Regional by Mr. Jeffrey P. Hoyle, Dartmouth Middle School, Dartmouth, MA 02747



Sometimes it helps to know how frequently letters appear in a typical paragraph.

Order of Frequency of Single Letters
E 12.31%
T 9.59%
A 8.05 %
O 7.94%
N 7.19%
I 7.18%
S 6.59%
R 6.03%
H 5.15%
L 4.03%
D 3.65%
C 3.20%
U 3.10%
P 2.29%
F 2.28%
M 2.25%
W 2.03%
Y 1.88%
B 1.62%
G 1.61%
V 0.93%
K 0.52%
Q Ç 0.22%
X 0.22%
J 0.10%
Z 0.09%









Behind the Bars: A Short Lesson on Codes

prepared for the NCTM Springfield Regional by Mr. Jeffrey P. Hoyle, Dartmouth Middle School, Dartmouth, MA 02747

Still need more help? Try this chart. Note: Those reading online will not find the chart helpful as the font didn't translate to html.It is actually an Appleworks font.

A= A,a
B= B,b
C=
D= D,d
E= E,e
F=
G=
H=
I= I,i
J=
K=
L= L,l
M=
N= N,n
O= O,o
P=
Q=
R=
S= S, s
T= T,t
U=
V=
W= W, w
X=
Y=
Z=



Behind the Bars: A Short Lesson on Codes
prepared for the NCTM Springfield Regional by Mr. Jeffrey P. Hoyle, Dartmouth Middle School, Dartmouth, MA 02747


The postal bar code is really a systematic listing of the ways to put three short and two long segments together.
Place value for the code goes 7-4-2-1-0. The large bars “tells” the number and the small bars the spaces. For example is equal to 1 (as the place value for 1 and 0 are selected). But the bar code is equal to 0
(as 7 and 4 would equal 11 and not a single digit).

Each digit in the code is converted as follows:








Behind the Bars: A Short Lesson on Codes
prepared for the NCTM Springfield Regional by Mr. Jeffrey P. Hoyle, Dartmouth Middle School, Dartmouth, MA 02747



Can you match the Postal Code to the correct address?




















Behind the Bars: A Short Lesson on Codes

prepared for the NCTM Springfield Regional by Mr. Jeffrey P. Hoyle, Dartmouth Middle School, Dartmouth, MA 02747





Needles Ribbon Lotion





Cookies CD Video













Behind the Bars: A Short Lesson on Codes
prepared for the NCTM Springfield Regional by Mr. Jeffrey P. Hoyle, Dartmouth Middle School, Dartmouth, MA 02747


The numbers on a UPC symbol are assigned by the Uniform Code Council (http://www.uc-council.org/).

The first digit to the left of the symbol is used to classify the item by type:

First Digit Meaning

0 Ordinary grocery item
1 Reserved
2 Products sold by weight (meat, cheese)
3 Health related products
4 UPC code used for items only sold in certain store1Ž2s
5 Coupon
6 Normal UPC code
7 Normal UPC code
8 Reserved
9 Reserved

The next five digits identify the manufacturer that makes the product. The numbers are again assigned by the Uniform Code Council. For example, 28000 is assigned to NESTLE FOOD COMPANY and 34000 to Hershey's.

The next five digits, numbers seven through eleven, represent the product number assigned by the company that makes it. It could identify product size, description, flavor, color etc.

The twelve or last digit is the check digit. This digit allows the scanner to see if the UPC symbol has been damagedú or changed in any way.

To find the check digit add the sum of the odd-spaced digits (the 1st, 3rd, 5th, 7th, 9th, 11th). Multiple the sum by 3. Save that as answer #1. Add up the even-spaced digits of the code (don't include the check digit! That's the one you're guessing). Add that answer to answer #1. The check digit will be whatever number you have to add to your last answer to get it up to the next multiple of 10.

For the UPC symbol above we would add “odd-spaced digits” 0+8+0+2+2+0. We would multiply the sum of 12 by 3 for a product of 36. We would then add the “even-spaced” numbers 2+0+0+4+1+0 = 7. Combine the two sums (36+7) for a total of 43. The check digit is the next highest multiple of ten or 7.

Behind the Bars: A Short Lesson on Codes
prepared for the NCTM Springfield Regional by Mr. Jeffrey P. Hoyle, Dartmouth Middle School, Dartmouth, MA 02747


Find the check digit ...
Marshmallow Fluff_____
OneSource Multivitamin ___
4C Bread Crumbs __
Premiere Magazine ___
Williams Lectric Shave ___


Is the following a valid UPC code? Explain.


______________________________________


Behind the Bars: A Short Lesson on Codes
prepared for the NCTM Springfield Regional by Mr. Jeffrey P. Hoyle, Dartmouth Middle School, Dartmouth, MA 02747


answers and bibliography:

1. A message was encoded by replacing each letter with the letter that comes before it in the alphabet. What does the following message say ?

BZM XNT RSTCDMSR CDBNCD SGHR ? VGZS ZANTS “Z” ?

Can you students decode this? what about the “a”?


2. A student assigned the numbers 1 through 26 to the letters A-Z in increasing order. Can you decode the following message ?

5 1 19 25 3 15 4 5
easy code


14 9 3 5 23 15 18 11
nice work


3. Another student assigned numbers to the letters as follows: A--1, B--4. C--7, D--10 etc. Can you determine the pattern and use that to decode the following message ?

67 13 ‘ 34 34 55 43 34 64 13 55 43 37 13 4 1 52 7 43 10 13 55
55 43 43 40

we’ll solve some bar codes soon


4. How would you decode the following message assuming it was generated using the same code ?

19 43 10 1 52 58 37 43 61 58 22

Go Dartmouth


5. Try to decipher this message:

CETTAEHONTENYMGIOEAGUAMHMTET

A 7X4 grid will give you: Can you meet me at the game tonight



6. The quote is from Jerry Seinfeld

“Life is truly a ride. We're all strapped in and no one can stop it. When the doctor slaps your behind, he's ripping your ticket and away you go. As you make each passage from youth to adulthood to maturity, sometimes you put your arms up and scream, sometimes you just hang on to that bar in front of you. But the ride is the thing. I think the most you can hope for at the end of life is that your hair's messed, you're out of breath, and you didn't throw up.”
-Jerry Seinfeld

Postal Match Answers

1) Men’s Health
2) Entertainment
3) Premiere
4) Sports Illustrated


UPC Bar Graph Answers

Fluff 4
Vitamins 4
Bread Crumbs 8
Premiere 3
Shave 8
No. Odd digit sum is 30. 30*3=90. Even digit sum is 20. Total of 110. Check digit should be 0.











Bibliography


books:

Eastaway, Rob and Jeremy Wynham, Why Do Buses Come in Threes? The Hidden Mathematics of Everyday Life, London, Robson Books Ltd., 1998

Segan, Carl, Contact , New York, Pocket Books, 1985

Singh, Simon, The Code Book, New York, Doubleday, 1999

other sources:

Chang, Aileen, “What’s Behind the Bars?”, Scholastic Math Magazine, November 1, 1991

“Codes, Error Detection, Error Correction”, Rutgers Leadership Program in Discrete Mathematics, Follow-up Session, December 1997

Powers, Sandra, Say What?” , NCTM Math Notes, September 1998

internet sources:

“Bar Code 1: A Web of Information About Bar Code” http://www.adams1.com/pub/russadam/barcode1.cgi

“Rutgers Leadership Program in Discrete Mathematics : K-8 Program” http://dimacs.rutgers.edu/lp/institutes/

“The Bar Code Server”
http://www.milk.com/barcode/

“Uniform Code Council”
http://www.uc-council.org/

“UPC and Bar Code Information” http://grover.mta.ca/upc/upcinfo.html

“What Is A Bar Code?” http://www.cedar.buffalo.edu/Adserv/postcode.html