What is wrong with my code? Task: Mathematics, test cases 4 and 5 failed. | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 1

What is wrong with my code? Task: Mathematics, test cases 4 and 5 failed.

Find which math expression matches the answer that you are given, if you have an integer answer, and a list of math expressions. Task: Test each math expression to find the first one that matches the answer that you are given. Input Format: Two inputs: an integer and a space separated string of math expressions. The following operations need to be supported: addition +, subtraction -, multiplication *, division /. An expression can include multiple operations. Output Format: A string that tells the index of the first math expression that matches. If there are no matches, output 'none'. Sample Input: 15 (2+100) (5*3) (14+1) Sample Output: index 1 https://code.sololearn.com/ciORXrxX0Z5B/?ref=app

26th Jun 2023, 12:35 PM
Monika Izydorczyk
Monika Izydorczyk - avatar
9 Answers
+ 1
https://code.sololearn.com/cGY3Qgx3fj6Z/?ref=app try this it's giving warning instead of int in for loop u need to use long unsigned int And check your input formats
26th Jun 2023, 4:14 PM
A S Raghuvanshi
A S Raghuvanshi - avatar
+ 1
Now check again I have modified the code little it's working fine for your given input I have tested well I have changed line no 49 15 (2+100) (5*3) (14+1)
27th Jun 2023, 5:09 PM
A S Raghuvanshi
A S Raghuvanshi - avatar
+ 1
Can you please provide the whole test cases and constraints
27th Jun 2023, 5:59 PM
A S Raghuvanshi
A S Raghuvanshi - avatar
+ 1
No, because I don't have PRO account so I can't see some test cases. I can see that they failed only.
27th Jun 2023, 6:02 PM
Monika Izydorczyk
Monika Izydorczyk - avatar
+ 1
This question is from code coach..?
27th Jun 2023, 6:03 PM
A S Raghuvanshi
A S Raghuvanshi - avatar
0
Thanks, but it still doesn't work
26th Jun 2023, 9:01 PM
Monika Izydorczyk
Monika Izydorczyk - avatar
0
Yes, that's true, it works for this input from example but test case 4 and 5 still fail. I don't know the contents of this test cases.
27th Jun 2023, 5:42 PM
Monika Izydorczyk
Monika Izydorczyk - avatar
0
Free or PRO, the test cases that are locked are still the same.
27th Jun 2023, 6:48 PM
Jan
Jan - avatar
0
Yes, it is from Code coach
27th Jun 2023, 7:07 PM
Monika Izydorczyk
Monika Izydorczyk - avatar