What am I missing | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

What am I missing

I made a credit card validator. It passed 6 out of 7 test cases. The one that failed it hidden. I can't figure out what I'm missing. The program uses the luhn formula which I broke into separated callable functions to modify vector components. https://code.sololearn.com/cBLhr6Jwm9V5/?ref=app

31st Oct 2022, 12:41 AM
Malachite
Malachite - avatar
3 Answers
+ 1
Thank you Bob_Li. You helped me spot the error. Plus I liked your solution
1st Nov 2022, 1:26 PM
Malachite
Malachite - avatar
0
observations: since you are using namespace std, you could leave out the "std::" from your code to reduce clutter. you are not taking advantage of c++ libraries, which would make your code much simpler. not everything have to be broken up to functions. It's an unnecessary complication for this task
31st Oct 2022, 2:22 AM
Bob_Li
Bob_Li - avatar
0
//Malachite modify this part: // function to minus 9 from any digit larger than 9 in the vector. vector<int> subNine(vector<int> &vect){ int temp; for(int i = 0; i < vect.size(); i++){ if(vect[i] > 9){ temp = vect[i] - 9; vect[i] = temp; }}return vect; }
31st Oct 2022, 3:13 AM
Bob_Li
Bob_Li - avatar