Sololearn: Learn to Code
New course! Every coder should learn Generative AI!
Try a free lesson
+ 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
Namit Jain - avatar
+ 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
Namit Jain - avatar
+ 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
Namit Jain - avatar
+ 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
Namit Jain - avatar
+ 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
Namit Jain - avatar
+ 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
Namit Jain - avatar
+ 6
Gorom_Pani It is showing index 1 🤔 When I put this input 🤔
23rd Sep 2020, 9:15 AM
Namit Jain
Namit Jain - avatar
+ 6
Gorom_Pani donno 😐😢
23rd Sep 2020, 9:44 AM
Namit Jain
Namit Jain - avatar
+ 6
Gorom_Pani your code is giving no output But mine is not 🤔 Did you copy pasted my complete code in cc Try it
23rd Sep 2020, 9:47 AM
Namit Jain
Namit Jain - avatar
+ 5
Gorom_Pani Follow the operator precedence Why are you adding 2 to i in line 42? Does your code work for 2 digit numbers also? Place some cout statements here and there to see what's going on 🙂
23rd Sep 2020, 5:54 PM
Namit Jain
Namit Jain - avatar
+ 4
Gorom_Pani If it runs perfectly then why did you ask the question? 😐 Try out the method told by me! That might help you 👍
23rd Sep 2020, 7:10 AM
Namit Jain
Namit Jain - avatar
+ 4
Gorom_Pani can you give a sample input and output 🤔 Is there any space between the operators and the numbers? I am interpreting the sample input is of the format: 12 (3*4)(3+4)(3-4)(8/2)
23rd Sep 2020, 8:17 AM
Namit Jain
Namit Jain - avatar
+ 4
Gorom_Pani I am asking for the sample input and output (that can be seen in the question page at the bottom) Why are you telling something else when I am asking one thing
23rd Sep 2020, 8:19 AM
Namit Jain
Namit Jain - avatar
+ 4
Lucas Kliemczak Ya! Python makes it easy! 🙂 It has a 2 line solution for this question! You will have to apply operator precedence too! What you can do? Find out where is '*' and '/'. Compare their index and findout the first least one! Apply the operator with that! And then move on to the next index! For example, 2*3+4*4/8 Indices of * are 0 and 2 Index of / is 3 (Only seeing the operators) Least out of 0,2,3 is 0 So we will solve for the 0 first 2*3 = 6 We have 6+4*4/8 Then we have 2,3 We will solve for 2 6+8/8 Then 3 6+1 And now we are left with addition and subtraction that is an easy task (no operator precedence concept required)
24th Sep 2020, 4:20 AM
Namit Jain
Namit Jain - avatar
+ 4
Namit Jain you know c++?
24th Sep 2020, 6:54 AM
The future is now thanks to science
The future is now thanks to science - avatar
+ 4
Samsil Arefeen Syntax don't matter actually 😅 Google helps me search about different syntax
24th Sep 2020, 7:11 AM
Namit Jain
Namit Jain - avatar
+ 4
24th Sep 2020, 7:12 AM
The future is now thanks to science
The future is now thanks to science - avatar
23rd Sep 2020, 8:07 AM
Namit Jain
Namit Jain - avatar
+ 2
I tried in java. My code ran properly, but in the code coach it fails in two tests. However, my algorithm seems to follow a different methodology. 🤔 https://code.sololearn.com/c4X90rlnJZxi/?ref=app
23rd Sep 2020, 10:15 PM
Lucas Kliemczak
Lucas Kliemczak - avatar
+ 2
Lucas Kliemczak It is showing error 😔
24th Sep 2020, 3:57 AM
Namit Jain
Namit Jain - avatar