+ 1

This is also need debug. Anyone help me to solve this?

https://www.sololearn.com/coach/96?ref=app Here is the code: https://sololearn.com/compiler-playground/clnYifADY0cd/?ref=app It works only five cases but Sololearn wants more

31st Mar 2024, 11:07 AM
Manish
2 odpowiedzi
+ 4
Manish , you have 2 for loops that are nested. this leeds to many unnecessary execution steps (291) to calculate one cc number. remove the inner loop. you can use an *if* conditional instead. check if the multiplication results in a value greater than 9. if yes: > subtract 9 from the product of the multiplication and store it at the index `i` in cc_number. if no:: > store the product of the multiplication as it is at index `i` in cc_number. the number of execution steps will be 39, and it should pass all test cases.
31st Mar 2024, 3:56 PM
Lothar
Lothar - avatar
+ 3
Manish , That link shows the directions for the Code Coach called Credit Card Validator. That's good so we can read the directions, but we can't read your code. You'll have to copy and paste your code into a separate file and share that link too. Then we can read it.
31st Mar 2024, 11:20 AM
Rain
Rain - avatar