Timeline for Simple credit card validation with Luhn's Algorithm
Current License: CC BY-SA 4.0
11 events
when toggle format | what | by | license | comment | |
---|---|---|---|---|---|
Mar 19 at 12:32 | comment | added | 301_Moved_Permanently |
Why not sum(get_digits(doubled)) every time and let that function handle the fact that it may have one or two digits? Also, you can easily get rid of the ceil(log10(number)) by turning the for loop into a while number: .
|
|
Sep 17, 2021 at 19:39 | comment | added | C.Nivs | @N3buchadnezzar hm, good catch, I was going to take this down anyways, but I'll rerun test cases when I update this to be a more satisfactory review | |
Sep 17, 2021 at 19:39 | comment | added | C.Nivs | @Reinderien Looking back, I think you might be right. I'll have to edit this to be a better answer, can't delete it since it's accepted | |
Sep 17, 2021 at 19:27 | comment | added | N3buchadnezzar | Have you checked that your algorithm is actually correct? It does not seem to pass the testcases here rosettacode.org/wiki/Luhn_test_of_credit_card_numbers#Python | |
Sep 14, 2021 at 14:55 | comment | added | Reinderien |
Hmmmm. You seem to want to micro-optimize beyond what's useful or probably even measurable (have you profiled the difference between string conversion and logarithms?), and some of your suggestions will harm performance rather than hurt it. For instance, rather than pushing for islice , you should simply have a tuple of integers and use regular [2:] slicing on it, which is both more legible and performant.
|
|
Sep 13, 2021 at 12:19 | history | edited | C.Nivs | CC BY-SA 4.0 |
added 16 characters in body
|
Sep 13, 2021 at 4:33 | comment | added | flamethrower10 | Awesome! I find this comprehensive review really well-explained. Thank you | |
Sep 13, 2021 at 4:32 | vote | accept | flamethrower10 | ||
Sep 13, 2021 at 2:25 | history | edited | C.Nivs | CC BY-SA 4.0 |
added 3 characters in body
|
Sep 13, 2021 at 2:15 | history | edited | C.Nivs | CC BY-SA 4.0 |
added 67 characters in body
|
Sep 13, 2021 at 2:06 | history | answered | C.Nivs | CC BY-SA 4.0 |