# DWITE Online Computer Programming Contest

## Simple Checksum

October 2008
Problem 2

A checksum is a type of simple error detection scheme, meant to catch incorrectly entered data such as typos. Credit cards, for example, use the Luhn algorithm to generate account numbers. Alternatively, a checksum could be a digit appended to the end of a number that needs to be later validated.

A super-simple scheme used to validate 6-digit student numbers is as follows:

1. Break the number up into 6 digits.
2. Add up all the digits together to get a new number.
3. Repeat the process until the result is only a single digit.
4. Convert the resulting digit to a capital letter, where A = 1, B = 2, etc.

Example:

1. 123456
2. 1 + 2 + 3 + 4 + 5 + 6 = 21
3. 2 + 1 = 3
4. 3 = C

The input file DATA2.txt will contain 5 lines, each being a 6-digit positive integer followed by a space and a capital letter. Numbers will not have leading zeros, and thus digits will never add up to 0.

The output file OUT2.txt will contain 5 lines, stating match or error, depending on if the number generates the same checksum letter as supplied or not.

Sample Input:
```123456 C
123456 A
100000 A
111111 F
111114 I```
Sample Output:
```match
error
match
match
match```