Tallying is a simple counting system that works in base 5. There are various different tallying systems used around the world, but the one that is used in most English-speaking countries is perhaps the most simple - count units by marking vertical lines, then for each 5th mark put a horizontal line through the previous collection of four. This clusters the tally marks in groups of 5 (and makes them easier to quickly count).
You are going to write a program that displays tally marks up to a given value. But, tallying in only base 5 is boring! Therefore, your program should also be able to display tallies in different bases.
Input
The input will be either one or two non-negative integer values separated by a comma (e.g. 9
or 8,4
). The first number is the value that should be displayed by the tally. The second value is the base of the tally. If the second value is not given, use base 5.
Output
The output will be the inputted value represented as ASCII art tally marks. Here are some examples you can test your program against - your output should match them exactly!
Input: 12
or 12,5
| | | | | | | | | |
-+-+-+-+- -+-+-+-+- | |
| | | | | | | | | |
Input: 7,3
| | | | |
-+-+- -+-+- |
| | | | |
Input: 4,2
| |
-+- -+-
| |
Input: 6,1
or 6,10
(notice the leading spaces)
| | | | | |
| | | | | |
| | | | | |
Note also that base 1 is intended to be inconsistent - only vertical lines should be used.
If either of the inputted values is 0, there should be no output whatsoever (and your program should end gracefully).
Rules
- This is code-golf, so the shortest correct implementation (in bytes) wins.
- Input/output can be in any suitable medium (e.g. stdin/stdout, file...).
- Input can be in the form of multiple command-line arguments or separated by spaces, etc. if it is more suitable for your target language.
- Trailing newlines are allowed in the output. Trailing spaces are not. This rule only applies when there is an output (i.e. not when the inputted value is 0).
- Your code must default to base 5 when no base is input.
6,1
look more like-+- -+- -+- -+- -+- -+-
? \$\endgroup\$-+-
would represent two, because there's a vertical line and a horizontal score through it. Base 1 would only have vertical lines. @AndoDaan ammended. \$\endgroup\$--- --- --- --- --- ---
then. For consistency with the other bases you should be putting a horizontal strike throughb-1
vertical lines. If it's intended to be inconsistent you should state that explicitly. \$\endgroup\$