A higher resolution is required to access the IDE
- 742
Learning Opportunities
This puzzle can be solved using the following concepts. Practice using these concepts and improve your skills.
Statement
Goal
International Standard Book Number (ISBN) is a unique numeric commercial book identifier.Before year 2007 ISBNs were
ISBN-10 check digit is calculated by Modulus
Example: 030640615?
0×10 + 3×9 + 0×8 + 6×7 + 4×6 + 0×5 + 6×4 + 1×3 + 5×2 = 130.
130 /
Check digit is the value needed to add to the sum to make it dividable by 11. In this case it is
So the valid ISBN is 0306406152.
In case 10 being the value needed to add to the sum, we use
ISBN-13 check digit is calculated by Modulus
Example: 978030640615?
9×1 + 7×3 + 8×1 + 0×3 + 3×1 + 0×3 + 6×1 + 4×3 + 0×1 + 6×3 + 1×1 + 5×3 = 93.
93 /
Check digit is the value needed to add to the sum to make it dividable by 10. So the check digit is
Your task is to validate a list of ISBNs.
A valid ISBN should contain the digits
Input
Line 1: An integer N for the number of ISBNs to verify.
Next N lines: One line for each ISBN to verify.
In this puzzle we assume all ISBNs have been normalized - have spaces and dash characters removed.
Next N lines: One line for each ISBN to verify.
In this puzzle we assume all ISBNs have been normalized - have spaces and dash characters removed.
Output
Line 1: A string Y invalid: where Y is the number of invalid ISBNs.
Next Y lines: One line for each invalid ISBN, in the same order as given in the inputs.
Next Y lines: One line for each invalid ISBN, in the same order as given in the inputs.
Constraints
1 ≤ N ≤ 500
1 ≤ Y ≤ N (i.e. there will always be at least one invalid ISBN in each case)
1 ≤ Y ≤ N (i.e. there will always be at least one invalid ISBN in each case)
Example
Input
6 0306406152 013603599X 1145185215X 9780306406157 9780306406154 978043551907X
Output
3 invalid: 1145185215X 9780306406154 978043551907X
A higher resolution is required to access the IDE