| import subprocess | |
| class MathEngine: | |
| def solve(expression: str) -> str: | |
| try: | |
| result = subprocess.check_output( | |
| ['python3', '-c', f'print({expression})'], | |
| timeout=2, | |
| text=True | |
| ) | |
| return result.strip() | |
| except Exception: | |
| return "Error: Unable to solve." |
| import subprocess | |
| class MathEngine: | |
| def solve(expression: str) -> str: | |
| try: | |
| result = subprocess.check_output( | |
| ['python3', '-c', f'print({expression})'], | |
| timeout=2, | |
| text=True | |
| ) | |
| return result.strip() | |
| except Exception: | |
| return "Error: Unable to solve." |