101
0/304
Loading content...
A rules engine stores named integer values and a set of comparison rules.
Table: variables
Table: expressions
Guarantees:
Task: Evaluate every rule in expressions by reading operand values from variables. For each expression row, output whether the comparison is true or false.
Output requirements:
Supported submission environments:
variables:
| name | value |
|------|-------|
| alpha| 42 |
| beta | 19 |
| gamma| 42 |
expressions:
| left_operand | operator | right_operand |
|--------------|----------|---------------|
| alpha | > | beta |
| beta | < | alpha |
| alpha | = | gamma |
| beta | = | gamma |[
{"left_operand":"alpha","operator":">","right_operand":"beta","value":"true"},
{"left_operand":"beta","operator":"<","right_operand":"alpha","value":"true"},
{"left_operand":"alpha","operator":"=","right_operand":"gamma","value":"true"},
{"left_operand":"beta","operator":"=","right_operand":"gamma","value":"false"}
]Each expression compares two looked-up integers from variables and emits a textual boolean.
variables:
| name | value |
|------|-------|
| x1 | -5 |
| x2 | -5 |
| x3 | 0 |
expressions:
| left_operand | operator | right_operand |
|--------------|----------|---------------|
| x1 | = | x2 |
| x1 | < | x3 |
| x3 | > | x2 |[
{"left_operand":"x1","operator":"=","right_operand":"x2","value":"true"},
{"left_operand":"x1","operator":"<","right_operand":"x3","value":"true"},
{"left_operand":"x3","operator":">","right_operand":"x2","value":"true"}
]Negative values and zero follow normal integer comparison semantics.
variables:
| name | value |
|------|-------|
| a | 100 |
| b | 100 |
expressions:
| left_operand | operator | right_operand |
|--------------|----------|---------------|
| a | < | b |
| a | > | b |
| a | = | b |[
{"left_operand":"a","operator":"<","right_operand":"b","value":"false"},
{"left_operand":"a","operator":">","right_operand":"b","value":"false"},
{"left_operand":"a","operator":"=","right_operand":"b","value":"true"}
]When both operand values are equal, only '=' evaluates to true.
Constraints