PY
py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
from sympy import *
a,b,c,d,e,f = symbols('a,b,c,d,e,f')
equations=['a-(b+c)','a-(b-c-(d+e))-f','(a-b)-((a+b)-(e+c-d))']
[print(f"{equation} \nsimplifies to\n{''.join(str(simplify(equation)).split(' '))}\n\n") for equation in equations]
'''
I want this in Python, it available in but too complicated
Simplify a given algebraic string of characters, ‘+’, ‘-‘ operators and parentheses. Output the simplified string without parentheses.
Examples:
Input : "a-(b+c)" Output : "a-b-c"
Input : "a-(b-c-(d+e))-f" Output : "a-b+c+d+e-f"
I tried
https://code.sololearn.com/cPiHvUryJoVI/?ref=app
'''
Enter to Rename, Shift+Enter to Preview
OUTPUT
Run