Problem 156 - Luhn algorithm

Back to General discussions forum

grey2010     2019-08-18 19:52:33

А по русски на форуме можно? А то читать я умею, но боюсь в изложении мыслей по английски не справлюсь. Потом скормлю это гугл переводчику... Итак: ищем поменяные местами номера. В процессе обнаруживается, что у некоторых вариантов есть более одного решения. К примеру: условие - 9672145652210149, мой ответ - 9672145652120149 (поменяны местами 10 и 11 элементы checksum = 60), ожидаемый от меня ответ - 9762145652210149 (поменяны местами 1 и 2 элемент checksum = 60). На данный момент это единственное, что делает мой ответ неправильным. Во время последней попытки из 54 номеров 9 имели более одного решения.

Let's translate!

Is it possible in Russian on the forum? And I can read, but I’m afraid I can’t cope in expressing my thoughts in English. Then I feed it to google translator ... So: we are looking for swapped numbers. The process reveals that some options have more than one solution. For example: the condition is 9672145652210149, my answer is 9672145652120149 (the checksum = 60 elements are interchanged 10), the expected answer from me is 9762145652210149 (the checksum element 60 and 1 are interchanged checksum = 60). At the moment, this is the only thing that makes my answer wrong. During the last attempt, out of 54 numbers, 9 had more than one solution.

Rodion (admin)     2019-08-19 17:08:31
User avatar

During the last attempt, out of 54 numbers, 9 had more than one solution.

I vaguely remember that someone have noted this before and that's true. So until the checker is updated, problem statement asks to find the first wrong position:

you are to find the leftmost pair which, if swapped, makes valid card number.

Sorry for inconvenience, I still hope to improve this checker one day.

А по русски на форуме можно? / Is it allowed to write in Russian

well, it is allowed, but should be avoided - though you did right providing translation so that people who don't read Russian are not offended :)

I understand that it could be bit hard to express thoughts in English for non-native speaker (for me too) - but nowadays learning English is crucial part of becoming good programmer... So we just regard it as additional training. :)

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