Prabhu excels at typing letters but struggles with symbols and numbers. To simplify, he…
- User
Prabhu excels at typing letters but struggles with symbols and numbers. To simplify, he decided to represent mathematical expressions using words. For numbers, he mentions each digit individually with the character 'c' to signify the entire word representing the number. Prabhu exclusively uses lowercase letters as he's not proficient with shift keys or caps lock.
For instance
111 is written as oneconecone
120 is written as onectwoczero
For a single operation: Operation Operand1 Operand2
Example: "add one two" represents 1+2.
For two functions: Operation1 Operation2 Operand1 Operand2 Operand3
Example: "add mul twoctwo threecone two" equals (22*31)+2.
For another variation: Operation1 Operand1 Operation2 Operand2 Operand3
Example: "add oneconecone div onectwoczeroczero twoctwo" equals 111+(1200/22).
Prabhu uses the following operations:
add for addition (e.g., 2+2=4). sub for subtraction (e.g., 2-2=0). mul for multiplication (e.g., 2*2=4). rem for remainder (e.g., 2%2=0). pow for power (e.g., 2^2=4). To convert and evaluate Prabhu's mathematical expression, output the result in numbers. If any word cannot be resolved as an operation or operand during evaluation, print "expression evaluation stopped invalid words present" If all words are recognized but the expression cannot be solved, print "expression is not complete or invalid"
Note:
The input does not contain float or negative numbers. Verify the correctness of words first, followed by correctness of expression.
- Assistant