Challenge:
You'll be given an ASCII image of a pile of weights as input, and must output the combined weight of the pile.
Format:
There are 5 different weights, weighing 1, 2, 5, 10, 20 Passerees (or some other arbitrary unit).
The weights looks like this, in ascending order:
1: __
|__|
2: ______
|______|
5: ______
| |
|______|
10: ______________
| |
|______________|
20: ____________________
| |
|____________________|
The weighs will be symmetrically placed (as in the example image), not necessarily in a sorted order. Weighs will share boundaries, where applicable:
Test cases:
You may use all the single weights as test cases too.
__
_|__|_
|______|
| |
|______|
1 + 2 + 5 = 8
____________________
| |
|____________________|
| |
|______________|
_|__|_
|______|
| |
|______|
20 + 10 + 1 + 2 + 5 = 38
______
|______|
|______|
|______|
|______|
2 + 2 + 2 + 2 = 8
Additional rules:
- You may not assume additional leading spaces. The largest weight will be all the way to the left.
- You may assume trailing spaces and newlines.
- You may assume there will be maximum 10 weights
- You may take the input on an optional format, but you can't substitute the characters used by something else
This is code-golf so the shortest code in bytes each languages wins. Explanations are encouraged as always.