LaunchpadChecksums

L6: Docking Codes

Every sleigh docking at Orimovo transmits a 16-digit code, one per line of your input. A code is genuine if it passes the Luhn check:

  • Starting from the rightmost digit, double every second digit (the 2nd, 4th, … from the right).
  • If doubling gives more than 9, subtract 9.
  • Add up all 16 digits (doubled or not). The code passes if the total is a multiple of 10.

For example:

4111111111111111
1234567812345678
8000000000000009
5555555555554444

The totals are 30, 68, 16 and 60, so 2 codes pass.

How many codes in your input pass the Luhn check?