Some background
Counting rods are small bars (3-14 cm long) that were used by mathematicians from many asian cultures for more than 2000 years to represent any whole number or fraction. (In this chqllenge we'l focus on unsigned integers though) There was also a written version, called rod numerals.
Here's how it works:
(If at any point you get confused, go check out the ascii representation of each digit and some examples I have included at the bottom)
Rod numerals are a true positional numeral system with digits for 1-9 and blank for 0. The digits consist of horizontal and vertical lines; the more lines, the higher the digit. Once you get past five, you put a horizontal line on top to add 5 to the numer of lines below. One vertical line is 1, two vertical lines 2, five vertical lines is 5, one vertical line with a horizontal line on top is 6, four vertical lines with a horizontal line on top is 9 (the highest digit).
A vertical 3 digit:
|||
|||
|||
|||
|||
To make reading rod numerals easier though, they used different notation for each alternating digit. The second notation swaps the role of the horizontal and vertical lines. so that 3 is represented by three horizontal lines and 8 by three horizontal lines with a vertical line on top.
A horizontal 8 digit:
|
|
__|__
_____
_____
Knowing which notation to use is easy, as previously said, tehy are used alternatingly and Sun Tzu wrote that "one is vertical, ten is horizontal". So the rightmost digit is vertical and we alternate from there on.
The challenge
These rods were used to represent negative numbers and fractions (as explained in the wikipedia article on them. For the purpose of this challenge we'll only focus on positive integers though. The objective is simple:
Write a function or full program that takes an integer value as input in any way and prints the rod numeral representation of this integer to STDOUT (you may also write to a file if that works out better). Shortest code in bytes wins.
Every digit will be represented by 5x5 ascii characters and seperated by two collumns of 5 spaces. The exact representation you'll use for each digit is as follows:
space between two digits (two colums):
0 digit, both vertical and horizontal (five columns):
1 digit, vertical:
|
|
|
|
|
2 digit, vertical:
| |
| |
| |
| |
| |
3 digit, vertical:
|||
|||
|||
|||
|||
4 digit, vertical:
|| ||
|| ||
|| ||
|| ||
|| ||
5 digit, vertical:
|||||
|||||
|||||
|||||
|||||
6 digit, vertical:
_____
|
|
|
|
7 digit, vertical:
_____
| |
| |
| |
| |
8 digit, vertical:
_____
|||
|||
|||
|||
9 digit, vertical:
_____
|| ||
|| ||
|| ||
|| ||
1 digit, horizontal:
_____
2 digit, horizontal:
_____
_____
3 digit, horizontal:
_____
_____
_____
4 digit, horizontal:
_____
_____
_____
_____
5 digit, horizontal:
_____
_____
_____
_____
_____
6 digit, horizontal:
|
|
|
|
__|__
7 digit, horizontal:
|
|
|
__|__
_____
8 digit, horizontal:
|
|
__|__
_____
_____
9 digit, horizontal:
|
__|__
_____
_____
_____
The digits are to be printed next to each other. Trailing spaces beyond the bounding box of the last digit are not allowed. Trailing spaces to complete the bounding box of the last digit(s) are required. You should end the output with a single trailing newline. Leading spaces that do not belong to the bounding box of the first digit are also forbidden.
Example output
Lines starting with >
are to be interpreted as input.
>12
| |
| |
| |
| |
_____ | |
>8037
| _____
| | |
__|__ _____ | |
_____ _____ | |
_____ _____ | |
>950
_____ _____
|| || _____
|| || _____
|| || _____
|| || _____