5 kyu

Graphics Series #1: barcode EAN-13 part1

67 of 74myjinxin2015

Description:

About barcode EAN-13

The EAN-13 barcode is used worldwide for marking products often sold at retail point of sale. I will not describe it in Kata in detail about it, because my poor English is certainly not better than Wikipedia. So, thanks to Wikipedia. Click here to view detailed information on barcode EAN-13.

Make sure you understand the rules, and then try to solve this kata ;-)

Rules of kata

First, in order to make your program easier, four data has been preload:

group  ----  First group of 6 digits
group=["LLLLLL","LLGLGG","LLGGLG",
       "LLGGGL","LGLLGG","LGGLLG",
       "LGGGLL","LGLGLG","LGLGGL",
       "LGGLGL"]
lcode  ----  L-digits
lcode=["0001101","0011001","0010011",
       "0111101","0100011","0110001",
       "0101111","0111011","0110111",
       "0001011"]
gcode  ----  G-digits
gcode=["0100111","0110011","0011011",
       "0100001","0011101","0111001",
       "0000101","0010001","0001001",
       "0010111"]
rcode  ----  R-digits
rcode=["1110010","1100110","1101100",
       "1000010","1011100","1001110",
       "1010000","1000100","1001000",
       "1110100"]

Hope that the data will help you solve this kata.

Second, your task is to write function readBarcode, two arguments will be given: first:the first digit; barcode, given by a string, length=3+42+5+42+3=95, like this:

  start 3 areas        center 5 areas                   end 3 areas    
       |                      |                             |
     "101...................01010..........................101"
                   |                           | 
      left 6 digit(6*7=42 areas)  right 6 digit(6*7=42 areas)

Please according to the two arguments to decode it, return the digital value of the barcode (a string with 13 digits).

Graphics Series:

Puzzles
Games

Stats:

CreatedJun 16, 2016
PublishedJun 17, 2016
Warriors Trained267
Total Skips43
Total Code Submissions458
Total Times Completed74
JavaScript Completions67
Python Completions10
Total Stars15
% of votes with a positive feedback rating97% of 36
Total "Very Satisfied" Votes34
Total "Somewhat Satisfied" Votes2
Total "Not Satisfied" Votes0
Total Rank Assessments6
Average Assessed Rank
5 kyu
Highest Assessed Rank
4 kyu
Lowest Assessed Rank
7 kyu
Ad
Contributors
  • myjinxin2015 Avatar
  • kazk Avatar
  • JohanWiltink Avatar
  • dfhwze Avatar
Ad