Is there a mistake in example for problem 156 (Task Luhn Algorithm)

Back to Problem Solutions forum

Yaan Prokofiev     2016-07-06 14:15:31
User avatar

Help me, pls!
Is there a mistake in example or there is a trick which i don't understand?

///////////////////////////////////////////////////////////////////////
Example:
input data:
4
?942682966937054
1217400151414995
2146133934?67114 <- problem is here
2553514623364925

answer:
3942682966937054 1217040151414995 2146133934667114 2553514623369425

///////////////////////////////////////////////////////////////////////

Problem with 3d line cheksum: 2146133934?67114 <- cheksum is 67

2146133934667114 <- (? = 6) => ( ? = 67 + 6*2 = 79)

79/10 = 7.9 => cheksum is incorect!

Quandray     2016-07-06 15:26:34
User avatar

6 * 2 gives a 2 digit number so you need to subtract 9
2146133934667114 <- (? = 6) => ( ? = 67 + 6*2-9 = 70)

Yaan Prokofiev     2016-07-07 11:47:23
User avatar

I was inattentive, my bad. Thanks for your response, i've fixed algorithm and it works now!

Please login and solve 5 problems to be able to post at forum