156 - LuhnAlgorithm

Back to General discussions forum

simonhugo     2023-02-09 09:59:06
User avatar

For the following entry 2931295293196099

the judge finds it wrong and proposes the exchange of the digits 14 and 15, but... both sums are equal -> 80 Why is the original entry not considered valid?

original 2931295293196099 seems to be OK 9+(92-9)+0+(62-9)+9+(12)+3+(92-9)+2+(52-9)+9+ (22)+1+(32)+9+(22) = 80

solution given by the judge 2931295293196909 interchanging those two digits does not alter the sum at all 9+(02)+9+(62-9)+9+(12)+3+(92-9)+2+(52-9)+9+(2 *2)+1+(32)+9+(2*2) = 80

simonhugo     2023-02-09 10:11:09
User avatar

Sorry, I answer myself. Rereading the statement

I deduce that it starts from the idea that there cannot be any entry that is correct. They all either have swapped digits, or are missing one

Gyulicaa     2023-09-28 15:17:43

Hello! We managed to solve the problem? I also have this problem, that based on the algorithm, the card number is good, but because it does not match the solution, it is not accepted.

Rodion (admin)     2023-09-28 16:56:11
User avatar

Hi! Can you please remind me what exactly problem? Could you perhaps share example of the value in input, your answer and expected answer?

Main things to note are - input entry is not initially correct and for swap you should return the leftmost possible pair.

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