Hello all,
I would like propose a new exercise called Barcode.
As the name imply, this exercise is focus on one of the ubiquitous invention of the last century: the barcode. The barcode has many variations and forms, so for this exercise I picked the Universal Product Code (UPC-A) as the subject to focus on.
Goals of the exercise:
Understand how barcode (UPC-A) works (it’s fun!)[Universal Product Code - Wikipedia]
tldr: UPC-A has 95 modules that create a bar of black and white stripes, we can represent it into a string of 1 and 0.
Utilize and practice already learned concepts
Concepts involved:
String manipulation
Dictionary
Regular expression
Some simple math
OOP / Class (optional)
“Pseudo” binary (These utilize 0 and 1 but their values are not typical of binary value)
Structure:
The exercise consider of 2 main parts: encoding (generator) and decoding
Encoding : take in a 12 digits number (or string) and return a 95 chars long string of 0 and 1.
Decoding: take in a 95 chars long string of 0 and 1, return a string of 12 digits
Progress:
At the moment i’ve finished the : exemplar, instructions, introduction story.
No test cases yet but the main idea is to check for : valid barcodes, valid barcodes (scan upside down), invalid barcodes (fail modulo check, too short, too long, invalid side etc), serialization and deserialization test.
Please let me know what you think!
I’m not entirely sure if this has been implemented on exercism or not, I did some check and look like it is in the clear.
Personally I know this is not wholly unique, since we already got rotational and simple cipher. But this might be a bit tougher and offer a different sets of challenge.
I’d appreciate any feedback and suggestions. Thanks for reading.
I don’t want to be a spoil-sport (I like barcodes - and 2D barcodes are even trippier!), but how would this be significantly different from ISBN Verifier or luhn or OCR Numbers?
I know its 12-digit vs 10-digit (or other length), and the validation is different (pseudo-binary encoding and modulo vs other algorithms), but it feels fairly similar to those other ones in the sense that you are arranging/encoding/decoding and validating numbers with a known algorithm.
Would there be a way to differentiate it more by using the actual bars or representations of bars (I guess that’s the pseudo binary part)? Or other scenarios?
And I am probably making too much of the ‘similarities’ – just because we have the other exercises doesn’t mean we can’t have this one, and that students can’t learn from it. After all, we have 6 generative song exercises, and all those are all very similar!
The bi-directionality of UPC-A codes is interesting – scanning upside down or ‘backward’ is a different sort of use case. And there could be some test cases around the guards. I also find it really interesting that the L side is even and the R side is odd.
I pretty much agree with all your points btw, Bethany.
It is not totally different from some of the exercises we already got, hence I want feedbacks to make it a bit more distinct. (If i could I would do a combo of this and the ISBN verfifier property together into a chain of exercises)
Would there be a way to differentiate it more by using the actual bars or representations of bars
We can’t really have a picture as input so I thought about using something like “❚” and " " as string, but I’m not sure that it would be very clear to read. And at the end of the day it go back to binary anyway, so i opt for the string of “0” and “1”
The bi-directionality of UPC-A codes is interesting
Yeah, the tests for its properties is actually the most interesting part of the exercise imo : bi-directionality, backward, number of 0 and 1 depend on left or right side. I did have some explanation of it in the doc.
I like barcodes - and 2D barcodes are even trippier!
YES! I actually want to do this. But obviously, I didn’t know about normal barcode so best to start with it first.
Also I wasn’t sure of how to represent the 2d barcode at first, but I suppose we can just do a square matrix, an array of strings for example. I’m open to pivot toward this but I would need to understand how the 2d one work first, and see how complex it would be.
Here is the repo if you want to take a gander. Like I said above, it is still very bare bone and unorganized. (I don’t want to put too much work into it and got reject ) Barcode
It is in powershell, but im sure you can read it just fine.
I found this on GitHub. Highly suspicious that it “just works” after install, but we could perhaps test it out in a test runner. It has both Python and JS dependancies, so it might bloat things.
Since its a font, it has a mapping, so I am assuming that once installed it can be used and compared as any other font/string. Not sure how the GH version differs from the google version.
There is also this font - which uses a parity table to ‘generate’ the bars. So there is more complexity there, and more testing would be needed. My bad, this one is not free, which is probably why they set it up with a parity table.