Question: for python 2.7, thank you The encoding scheme for a five-digit zip code is shown in the above figure. The five zipcode digits are encoded
for python 2.7, thank you
The encoding scheme for a five-digit zip code is shown in the above figure. The five zipcode digits are encoded using five clusters of bars, where each bar is one of two heights: short or tall. The five encoded digits are followed by a check digit, which is computed as follows: Add up all the digits in the zipcode to make the sum Z Choose the check digit C so that Z +C is a multiple of 10 For example, the zipcode 95014 has a sum of Z-9+5 +0+1+4- 19, so the check digit C is 1 to make the total sum Z +C equal to 20, which is a multiple of 10 Each digit of the zipcode, as well as the check digit, is individually encoded according to the table below, where 0 denotes a short bar and 1 a tall bar: Digit Bar 1 Bar 2 (weight 4) Bar 5 (weight 0) ar (weight 7) (weight 2) (weight 1) 0 0 0 0 0 Decoding from the bar pattern to the original digit can be easily computed using the column weights 7, 4, 2, 1, and 0. For example, 01100 (short, tall, tall, short, short) decodes to: Unfortunately, the digit 0 is an exception. If you apply the same decoding algorithm for 0, you end up with: 1x7+1x4+0x2+0x1+00-11
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
