The missing parenthesis
Description
Discuss (9 comments)
In an effort to help users who forget to put parenthesis around their expressions, we designed this puzzle to use artificial intelligence to find the most likely solution. The artificial assumption makes use of the common sense expression: Bigger is better.
The puzzle will take expressions of the form:
a op1 b op2 c
where
The input file is formatted as follows:
For each expression you should print its "bigger is better" value.
For the previous example:
The puzzle will take expressions of the form:
a op1 b op2 c
where
- a, b, c are integers
- op1, op2 are operators: +,- or *
Input Specifications
Your program must take one and only one command line argument: the input file.The input file is formatted as follows:
- the first line contains the number n of expressions to evaluate
- the n following lines each contain an expression of the form
a op1 b op2 c where
- a, b, c are integers
- op1, op2 are operators: +,- or *
5 2 - 9 * 8 6 * 8 + 1 9 + 10 - 9 7 - 7 + 7 5 * 5 * 3
Output Specifications
The output should be printed on the standard output (printf, etc...)For each expression you should print its "bigger is better" value.
For the previous example:
-56 54 10 7 75
© CoderCharts - All Rights Reserved
| Type | Puzzle | Pass | 239 | Fail | 121 | ||
| Scoring | Language | Level | Easy | Points | 100 | ||
| Tags | arithmetic, expression evaluation, string manipulation | ||||||
Unit Tests
| Name | CPU Unit | Memory Unit |
|---|---|---|
1000 expressionsThis test has at 1000 expressions to evaluate |
Confirm that you want to switch languages
Your current edits will be lost.
Confirm that you wish to load a previous submission
Your current edits will be lost.