DWITE '08 R1 #2 - Simple Checksum

View as PDF

Submit solution

Points: 3
Time limit: 2.0s
Memory limit: 64M

Problem type
Allowed languages
Ada, Assembly, Awk, Brain****, C, C#, C++, COBOL, CommonLisp, D, Dart, F#, Forth, Fortran, Go, Groovy, Haskell, Intercal, Java, JS, Kotlin, Lisp, Lua, Nim, ObjC, OCaml, Octave, Pascal, Perl, PHP, Pike, Prolog, Python, Racket, Ruby, Rust, Scala, Scheme, Sed, Swift, TCL, Text, Turing, VB, Zig
DWITE Online Computer Programming Contest, October 2008, Problem 2

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

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

  • Break the number up into 6 digits
  • Add up all the digits together to get a new number
  • Repeat the process until the result is only a single digit
  • Match the resulting digit to the capital letter of alphabet, in that position


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

The input will contain 5 lines, 6-digit positive integers, 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 will contain 5 lines, stating match or error, depending 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


Attribution-NonCommercial-ShareAlike 3.0 Unported (CC BY-NC-SA 3.0) Problem Resource: DWITE


There are no comments at the moment.