A higher resolution is required to access the IDE
Learning Opportunities
This puzzle can be solved using the following concepts. Practice using these concepts and improve your skills.
Statement
Goal
The Japanese abacus (soroban) is a calculation tool that uses vertical columns (The abacus, with all columns set to value
_________________________________________________________
/ _____________________________________________________ \
| | <_> <_> <_> <_> <_> <_> <_> <_> <_> <_> <_> <_> <_> | |
| |__|___|___|___|___|___|___|___|___|___|___|___|___|__| |
| __________________________.__________________________ |
| | | | | | | | | | | | | | | | |
| | <_> <_> <_> <_> <_> <_> <_> <_> <_> <_> <_> <_> <_> | |
| | <_> <_> <_> <_> <_> <_> <_> <_> <_> <_> <_> <_> <_> | |
| | <_> <_> <_> <_> <_> <_> <_> <_> <_> <_> <_> <_> <_> | |
| |_<_>_<_>_<_>_<_>_<_>_<_>_<_>_<_>_<_>_<_>_<_>_<_>_<_>_| |
\_________________________________________________________/
To read the number displayed on the abacus, follow these steps in order:
1. Find the dot (
2. Determine each place value from the bead positions in each column. If the top bead is shifted down towards the middle row of the abacus frame, that bead adds
3. String all place values together (accounting for the decimal point) and truncate unnecessary leading and/or trailing zeroes and/or the radix character (
For example, the following ASCII abacus represents the number
_________________________________________________________
/ _____________________________________________________ \
| | <_> <_> <_> <_> <_> <_> | | | | | <_> <_> | |
| |__|___|___|___|___|___|__<_>_<_>_<_>_<_>_<_>__|___|__| |
| __________________________.__________________________ |
| | | | <_> <_> <_> <_> | <_> <_> <_> <_> | | | |
| | <_> <_> | <_> <_> <_> <_> | <_> <_> <_> <_> <_> | |
| | <_> <_> <_> | <_> <_> <_> <_> | <_> <_> <_> <_> | |
| | <_> <_> <_> <_> | <_> <_> <_> <_> | <_> <_> <_> | |
| |_<_>_<_>_<_>_<_>_<_>__|__<_>_<_>_<_>_<_>__|__<_>_<_>_| |
\_________________________________________________________/
Now you try!
Abacus (soroban): https://en.wikipedia.org/wiki/Soroban
ASCII art credit: https://ascii.co.uk/art/abacus
Input
11 lines: A 59-character string, denoting a single row of the ASCII abacus.
Output
Line 1: The value represented by the abacus in simplified form (with unnecessary leading/trailing zeroes removed). If the decimal value of the number is zero, omit the radix character (. ) from the output as well.
Constraints
The abacus frame will always be in the same position, as shown in the given examples.
Each vertical column (| ) will always be in the same position, as shown in the given examples.
There are only 10 bead positions (denoting0 -9 ), as shown in the given examples.
The middle row of the abacus frame will always have exactly one dot (. ).
Each vertical column (
There are only 10 bead positions (denoting
The middle row of the abacus frame will always have exactly one dot (
Example
Input
_________________________________________________________ / _____________________________________________________ \ | | <_> <_> <_> <_> <_> <_> | | | | | <_> <_> | | | |__|___|___|___|___|___|__<_>_<_>_<_>_<_>_<_>__|___|__| | | __________________________.__________________________ | | | | | <_> <_> <_> <_> | <_> <_> <_> <_> | | | | | | <_> <_> | <_> <_> <_> <_> | <_> <_> <_> <_> <_> | | | | <_> <_> <_> | <_> <_> <_> <_> | <_> <_> <_> <_> | | | | <_> <_> <_> <_> | <_> <_> <_> <_> | <_> <_> <_> | | | |_<_>_<_>_<_>_<_>_<_>__|__<_>_<_>_<_>_<_>__|__<_>_<_>_| | \_________________________________________________________/
Output
12345.6789
A higher resolution is required to access the IDE