UpAboutMore


Breaking the Postal Code

Voice Card  -  Volume 1  -  John Card Number 19  -  Wed, Aug 31, 1988 4:28 AM







Have you ever wondered about those little strings of long and short line segments that appear at the bottom of reply mail cards and computer generated envelopes? One evening last week (when I should have been working on Archipelago) I decided to embark on a Project Of ABSOLUTELY NO Apparent Redeeming Value: breaking the postal code. I must admit that this was not exactly like breaking the Enigma code in World War II, especially since this code is designed to catch errors, not conceal vital secrets.

Anyway, I figured it out. The lines represent a binary number (tall lines are 1's, short lines are 0's) and the number is simply the 5 or 9 digit zipcode (plus an extra parity digit). Also, the number begins and ends with an extra 1 bit (a tall line). Each digit is represented by 5 bits as follows:

0 - 11000 1 - 00011 2 - 00101 3 - 00110 4 - 01001 5 - 01010 6 - 01100 7 - 10001 8 - 10010 9 - 10100

This scheme is known as a 2-out-of-5 code; it uses all ten possible combinations of two 1's in a five bit code word. This is handy because if ever a postal sorting machine reads a digit without exactly two 1's, it knows that there's some kind of error (like a smear across the page).

As an added check, a parity digit is added to the end so that the sum of all the digits is an even multiple of ten. For example, my zip code is 59633 and since 5+9+6+3+3=26, a 4 is added to the end to bring the sum up to 30. The computer adds all the digits together and if the sum is not a multiple of ten, it knows that something is wrong. In many cases codes like this can not only detect an error, but deduce what the error is and automatically correct it.

As far as I can tell, knowing how this code works will not do any of us the slightest bit of good, but after all, Archipelago IS the Journal for the Royal Society of Ponarvians and this is a classic PONARV. So if any of you have similar projects in the works, please report on your progress and I will do the same!




UpAboutMore