**New course!**Every coder should learn

**Generative AI!**

+ 10

Sample input:
12
(3*4) (3+4) (3-4) (8/2)
Sample output:
index 0
Right?
https://code.sololearn.com/cFEmiMZYr6B2/?ref=app

+ 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)

+ 7

Gorom_Pani I put an input:
12
(8*5)(3*4)(4+3)
And it shows many errors 🤔

+ 7

Gorom_Pani The sample input you gave doesn't have spaces 🤔
And what's the output?
Index 1?

+ 7

Gorom_Pani copy the sample input and output as it is plss 🙏
Don't type it
Is there a space between the brackets?

+ 6

Gorom_Pani Can you plss tell the sample output 😐
I am asking for it the 3rd time 😢

+ 6

Gorom_Pani It is showing index 1 🤔
When I put this input 🤔

+ 6

Gorom_Pani donno 😐😢

+ 6

Gorom_Pani your code is giving no output
But mine is not 🤔
Did you copy pasted my complete code in cc
Try it

+ 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 🙂

+ 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 👍

+ 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)

+ 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

+ 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)

+ 4

Namit Jain you know c++?

+ 4

Samsil Arefeen Syntax don't matter actually 😅
Google helps me search about different syntax

+ 4

Namit Jain nice.

+ 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

+ 2

Lucas Kliemczak It is showing error 😔