This proposal had few attention for 8 months (though an answer was posted in the sandbox at that time), so I decided to post it anyway.
Introduction
Napier's bones is a calculation tool, which helps speeding up the calculation of multiplication, division and digit-by-digit square root extraction by turning n-digit-by-1-digit multiplications into table look-ups. Napier's bones consists of rods marked with the multiples of a single-digit number, and a board with a set of numbers on the left, on which the rods can be arranged. The board and the rods look like this (All appearances of the rods are in the Sample section):
Rod Board
+-----------------------------------------------+
| +------------------------------------------+|
+---+ | | ||
| 4 | | | ||
+---+ | | ||
|0 /| | | ||
| / | | 1 | ||
|/ 4| | | ||
+---+ | | ||
|0 /| | | ||
| / | | 2 | ||
|/ 8| | | ||
+---+ | | ||
|1 /| | | ||
| / | | 3 | ||
|/ 2| | | ||
+---+ | | ||
|1 /| | | ||
| / | | 4 | ||
|/ 6| | | ||
+---+ | | ||
|2 /| | | ||
| / | | 5 | ||
|/ 0| | | ||
+---+ | | ||
|2 /| | | ||
| / | | 6 | ||
|/ 4| | | ||
+---+ | | ||
|2 /| | | ||
| / | | 7 | ||
|/ 8| | | ||
+---+ | | ||
|3 /| | | ||
| / | | 8 | ||
|/ 2| | | ||
+---+ | | ||
|3 /| | | ||
| / | | 9 | ||
|/ 6| | | ||
+---+ | | ||
| +------------------------------------------+|
+-----------------------------------------------+
Challenge
This challenge is to write a function or program which receives a natural number as input, and outputs the arrangement of the rods, as if a calculation were in progress, on the board as an ASCII art, according to the input, having the code as short as possible. The top row of the rods will assemble that number you have inputted.
Requirements
The input can be an argument of the function or program, or an input from STDIN. Please indicate your choice of input format. Accepted formats are as follows:
- An integer representing the number;
- A string representing the number; or
- A list of characters representing the digits of the number.
The output can be directly printed to STDOUT, or returned from the function as a string. Please refer to the Sample section.
- You can assume that the input will always be a valid representation of the number, i.e. the number matches the regex
[1-9][0-9]*
. - You must support all valid inputs in the range
[1, 2147483648)
. Larger ranges are absolutely welcomed. - You must leave no space around the rods.
- Standard loopholes apply.
Sample Input/Output
Input: 1234567890
Output:
+-------------------------------------------------------+
| +--------------------------------------------------+|
| |+---++---++---++---++---++---++---++---++---++---+||
| || 1 || 2 || 3 || 4 || 5 || 6 || 7 || 8 || 9 || 0 |||
| |+---++---++---++---++---++---++---++---++---++---+||
| ||0 /||0 /||0 /||0 /||0 /||0 /||0 /||0 /||0 /||0 /|||
| 1 || / || / || / || / || / || / || / || / || / || / |||
| ||/ 1||/ 2||/ 3||/ 4||/ 5||/ 6||/ 7||/ 8||/ 9||/ 0|||
| |+---++---++---++---++---++---++---++---++---++---+||
| ||0 /||0 /||0 /||0 /||1 /||1 /||1 /||1 /||1 /||0 /|||
| 2 || / || / || / || / || / || / || / || / || / || / |||
| ||/ 2||/ 4||/ 6||/ 8||/ 0||/ 2||/ 4||/ 6||/ 8||/ 0|||
| |+---++---++---++---++---++---++---++---++---++---+||
| ||0 /||0 /||0 /||1 /||1 /||1 /||2 /||2 /||2 /||0 /|||
| 3 || / || / || / || / || / || / || / || / || / || / |||
| ||/ 3||/ 6||/ 9||/ 2||/ 5||/ 8||/ 1||/ 4||/ 7||/ 0|||
| |+---++---++---++---++---++---++---++---++---++---+||
| ||0 /||0 /||1 /||1 /||2 /||2 /||2 /||3 /||3 /||0 /|||
| 4 || / || / || / || / || / || / || / || / || / || / |||
| ||/ 4||/ 8||/ 2||/ 6||/ 0||/ 4||/ 8||/ 2||/ 6||/ 0|||
| |+---++---++---++---++---++---++---++---++---++---+||
| ||0 /||1 /||1 /||2 /||2 /||3 /||3 /||4 /||4 /||0 /|||
| 5 || / || / || / || / || / || / || / || / || / || / |||
| ||/ 5||/ 0||/ 5||/ 0||/ 5||/ 0||/ 5||/ 0||/ 5||/ 0|||
| |+---++---++---++---++---++---++---++---++---++---+||
| ||0 /||1 /||1 /||2 /||3 /||3 /||4 /||4 /||5 /||0 /|||
| 6 || / || / || / || / || / || / || / || / || / || / |||
| ||/ 6||/ 2||/ 8||/ 4||/ 0||/ 6||/ 2||/ 8||/ 4||/ 0|||
| |+---++---++---++---++---++---++---++---++---++---+||
| ||0 /||1 /||2 /||2 /||3 /||4 /||4 /||5 /||6 /||0 /|||
| 7 || / || / || / || / || / || / || / || / || / || / |||
| ||/ 7||/ 4||/ 1||/ 8||/ 5||/ 2||/ 9||/ 6||/ 3||/ 0|||
| |+---++---++---++---++---++---++---++---++---++---+||
| ||0 /||1 /||2 /||3 /||4 /||4 /||5 /||6 /||7 /||0 /|||
| 8 || / || / || / || / || / || / || / || / || / || / |||
| ||/ 8||/ 6||/ 4||/ 2||/ 0||/ 8||/ 6||/ 4||/ 2||/ 0|||
| |+---++---++---++---++---++---++---++---++---++---+||
| ||0 /||1 /||2 /||3 /||4 /||5 /||6 /||7 /||8 /||0 /|||
| 9 || / || / || / || / || / || / || / || / || / || / |||
| ||/ 9||/ 8||/ 7||/ 6||/ 5||/ 4||/ 3||/ 2||/ 1||/ 0|||
| |+---++---++---++---++---++---++---++---++---++---+||
| +--------------------------------------------------+|
+-------------------------------------------------------+
Victory Condition
This is a code-golf, so the shortest code wins.