+ 17

# Code Coach problem Mathematics

Hello guys I made this code in C++ for Mathematics and this code's runtime is so much I mean it takes long to see the output.please modify this code: https://code.sololearn.com/c6hejYxEII4x/?ref=app Edit:the problem is solved but whats the problem with mines

23rd Sep 2020, 6:49 AM
Gorom_Pani
+ 10
Sample input: 12 (3*4) (3+4) (3-4) (8/2) Sample output: index 0 Right? https://code.sololearn.com/cFEmiMZYr6B2/?ref=app
23rd Sep 2020, 9:06 AM
Namit Jain
+ 14
Steps to be followed: 1. Take the required int/float input and in the next line take a sring input for the complete line! 2. Remove the first and the last element of the string i.e. '(' and ')' and you will get some sought of this: str = "2+5)(3+5)(6*5)(1*2"; 3. Split the string into a list by using the split function. Something like: str.split(")("); And the new list will be: ["2+5", "3+5", .....] 4. You will get some equations that you have to evaluate (that's an easy task, tell me if you want explanation of this too)
23rd Sep 2020, 7:03 AM
Namit Jain
+ 10
Namit Jain think those equations with braces as an element of an array then the (4*3) is index 1 Hope you understood edit: the sample input have spaces
23rd Sep 2020, 9:03 AM
Gorom_Pani
+ 10
Namit Jain Sample Input: 15 (2+100) (5*3) (14+1) Sample Output: index 1
23rd Sep 2020, 9:11 AM
Gorom_Pani
+ 9
Namit Jain Sorry for not undrrstanding you talks Sample input: 12 (5+5) (4*3) (7+3) Sample input: Index 1
23rd Sep 2020, 8:45 AM
Gorom_Pani
+ 8
Namit Jain you gave 3 inputs where index 1 is 4*3
23rd Sep 2020, 8:56 AM
Gorom_Pani
+ 7
Gorom_Pani I put an input: 12 (8*5)(3*4)(4+3) And it shows many errors π€
23rd Sep 2020, 7:13 AM
Namit Jain
+ 7
Gorom_Pani The sample input you gave doesn't have spaces π€ And what's the output? Index 1?
23rd Sep 2020, 8:46 AM
Namit Jain
+ 7
Namit Jain damn it! Sololearn is cc test cases are showing that no output as outputπ₯π₯π₯ But your and mine code is absolutly right!?
23rd Sep 2020, 9:08 AM
Gorom_Pani
+ 7
Gorom_Pani copy the sample input and output as it is plss π Don't type it Is there a space between the brackets?
23rd Sep 2020, 9:10 AM
Namit Jain
+ 7
Samsil Arefeen Yes he knows it better
24th Sep 2020, 6:56 AM
Gorom_Pani
+ 6
Namit Jain my code is right but there is something for which its giving the output after a very long time and sometime don't even give it But if I place the s's value after declaration and target's also the code rund perfectly!
23rd Sep 2020, 7:05 AM
Gorom_Pani
+ 6
Namit Jain I also have done the same please check out the code I also put those equations in a list and then evaluate the strings but there must be some fishy with input please check the code
23rd Sep 2020, 7:11 AM
Gorom_Pani
+ 6
Yes cause SL compiler needs vector size or string size typecasting but others don't want it wait lemme fix those I had fix those already but forgot to saveπ Anyways if I fix those errors the code will take long time for output you can see
23rd Sep 2020, 7:15 AM
Gorom_Pani
+ 6
Namit Jain now I have fix those but there shows no output while my code is right! edit: besides i have coded this in laptop
23rd Sep 2020, 7:17 AM
Gorom_Pani
+ 6
Namit Jain yes there is spaces
23rd Sep 2020, 8:20 AM
Gorom_Pani
+ 6
Namit Jain you might use stringstreams for spliting
23rd Sep 2020, 8:20 AM
Gorom_Pani
+ 6
Gorom_Pani Can you plss tell the sample output π I am asking for it the 3rd time π’
23rd Sep 2020, 8:39 AM
Namit Jain
+ 6
Gorom_Pani It is showing index 1 π€ When I put this input π€
23rd Sep 2020, 9:15 AM
Namit Jain
+ 6
Gorom_Pani donno ππ’
23rd Sep 2020, 9:44 AM
Namit Jain
Hot today
SQL