File size: 383 Bytes
c397cfe | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 | import subprocess
class MathEngine:
@staticmethod
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." |