Given an input of 3 single-digit positive integers representing a set of weights, output an ASCII representation of a seesaw with the weights placed on it so that it is in balance around a central pivot, taking lever effects into account.
Each number has a weight equal to its value. The torque of each number is the weight multiplied its the distance from the center in characters. For the seesaw to be in balance, the sum torque of the weights on the left of the seesaw must equal that of those on the right, like this.
3 integers in the range of 1-9. You can input the integers however is convenient, e.g. a tuple, 3 comma-separated values etc. However your program must be able to handle numbers input in any order (i.e. no assuming the values will be sorted). Duplicate numbers may be input (e.g. 2,3,2).
The inputs will always mathematically allow for a valid output, otherwise the input is not valid.
The output should be a 2-line ASCII representation of the seesaw with the weights placed on it. On the first line are the digits, spaced in order to balance them on the seesaw.
Numbers may not be placed in the very center of the scale, where the distance and therefore the torque would be zero. Valid distances from the center range from 1-10 characters inclusive to the left or right of the pivot.
In the spaces unoccupied by the numbers are 18 underscore characters (a center underscore and 10 on each side, minus the 3 positions occupied by the numbers). On the last line is a single caret character aligned with the center of the scale, representing the pivot.
7*2 = 4*2 + 2*3
Numbers can be output on either side, for example this would also be valid:
2*3 + 4*2 = 7*2
Numbers can be placed anywhere on the scale as long as they balance, e.g:
5*5 = 1*4 + 3*7
5*6 = 1*3 + 3*9
5*6 = 1*6 + 3*8
Your program only has to output one of the valid outputs. It does not have to output an error if the input is not valid.
- This is code-golf so the shortest program in bytes wins
- Program may be a stand-alone or a function that accepts the numbers as input and returns a string.
- Trailing newline and white-space on last line is optional
- If you don't know what a seesaw is, it's also known as a teeter-totter or a teeterboard.