Background
You have recently been hired by a small accounting firm. The world of accounting is somewhat foreign to you, so you're not sure whether you are following all the professional guidelines. In particular, you don't know when you should round all those numbers, and in which direction, so most of the time you just wing it and hope for the best.
Input
Your input is a single string that represents a simple calculation.
It contains some number of nonnegative integers delimited by the characters +-*/
.
The string reads from left to right, and the normal precedence rules are ignored, so "23+1*3/4"
means "start with 23, add 1, multiply by 3, and divide by 4", the result being 18.
The input will not contain numbers that start with 0
(except 0
itself), nor a division by zero.
Output
At each stage of the calculation, you can either round the result up or down to the nearest integer, or keep it as it is. Finally, you round either up or down to obtain a integer result. Your output is the list of integers that may result from such a calculation, sorted and without duplicates.
Rules
You can write either a full program or a function. The lowest byte count wins, and standard loopholes are disallowed.
Test Cases
"42" -> [42]
"2+0+4-0" -> [6]
"23+1*3/4" -> [18]
"5/2" -> [2,3]
"5/2+7/3*6-1" -> [17,18,19,23]
"23/2/2*30-170/3" -> [-7,-6,-2,-1,0,1,3,4]
"1/3*2*2*2*2*2*2" -> [0,16,20,21,22,24,32,64]
"1/3*9" -> [0,3,9]
1/3*9
, which may fail if you use floating point numbers. \$\endgroup\$