💶
Euro Counterfeits
Week 44
It's 2012 and you are working with all European banks to implement a counterfeiting detection & note-tracking technique based on the serial numbers of the 2nd generation Euro notes that will be introduced in the upcoming years
[Note: these notes are the most recent series, also called the Europa series - if you happen to have any Euros, you can test your program with their serial numbers too]
Bank note serial numbers should pass 3 checks in the following order and remaining checks should be skipped if a previous check has failed for that note (e.g. if check 1 fails, then checks 2 and 3 should be skipped) - the error message your program should output if this check fails is shown in brackets too:
- Serial numbers should be 2 letters, followed by 10 digits 0-9 (error: "wrong format")
- First letter represents printing works that created the bank note - the valid list is shown below (error: "non-existent printing works")
- Correct checksum value according to algorithm outlined later on the page (error: "wrong checksum")
As stated, the first letter represents the printing works the note was printed at and is given in both JSON and CSV format below - just use whatever format is more convenient for you. If you are interested, the data was obtained from this page (some control codes are missing - so use the JSON/csv below, which only includes the printing works with known/in use control codes)
...or the same data, as a CSV:
The checksum is calculated as follows:
- Convert second letter to its letter index, starting at 2 - i.e. A = 2, B = 3...Z = 27
- Add this letter index and all the remaining digits together to get your sum
- Add the individual digits of this calculated sum together until you are left with only a single digit (e.g. 67 would be 6 + 7 = 13...13 is still more than 1 digit, so then do 1 + 3 = 4...4 is only 1 digit, so stop)
- If the check digit we calculated is equal to the printing work's control code, then the checksum is valid
Let's look at two specific examples of VA0436214792 and WT9876516789:
As stated, your program should check the 3 requirements listed at the top of this challenge in that order and output only the first error for each bank note - i.e. if a note fails checks 1, then the program shouldn't bother doing checks 2 or 3, hence only the first error message would be output
If you want to try some more examples/your own notes for practice/curiosity, you can try this serial number checker
Here is some example output featuring 10 notes - your program should output data in exactly this format, with these green/red circle emojis (🟢🔴) to indicate valid/invalid notes, along with the first error message for each note if appropriate and counterfeit/total count summary at the end
Remember, the errors should be checked in order (format, existence of printing works, valid checksum) - the note with serial "A123456" would fail all 3 checks, but since the first check failed, then only that error is output and remaining checks aren't performed for that note
For your program, you should check and output the summary in the format above for the array of these 1000 notes:
Paste your answer below:
Hints
Hints will be released at the start of each of the following days - e.g. the start of day 3 is 48 hours after the challenge starts
| Release Day | Hint |
|---|---|
| 2 |