Overview
Given a 3 line string, figure out if the structure falls to the left, balances, or falls to the right.
Input structure
You can imagine the structure as metal rod with stuff on top, all being balanced on top of a vertical rod.
1 7 4 a
===============
|
The first line is the items. Each item's weight is calculated as the ascii value of the character minus 32. (Characters under 32 aren't considered and spaces weigh 0). Keep in mind that an item's force on the rod is its weight times the distance to the pivot point.
The second line is the rod. Each length of rod weighs 1 unit by itself. This line is exclusively equals signs (=
).
The third line is the pivot point. This can be placed anywhere, and is represented by a number of spaces followed by a single pipe (|
) character.
Examples
Input:
===== |
Output: Balance
Input:
===== |
Output: Falls left
Input:
% ===== |
Output: Balance (Because %
weighs enough to counteract the weight of the left side of the rod)
Input:
a a ======= |
Output: Falls right (because the a
on the right is further away from the pivot point)
Input:
1 7 4 A
===============
|
Output: Falls left
Input:
1 7 4 a
===============
|
Output: Falls right (lower case letters are heavy!)
Input:
$ ~
===============
|
Output: Balance
Notes
- Trailing whitespace is permitted, leading whitespace is not.
- Your program may output in whatever format you like, as long as there are 3 distinct outputs for left, balance, and right.
- Your program must accept the format shown as input.
- This is code-golf so the shortest code in bytes wins