You may have seen something called a "perpetual dice calendar":
Two 6-sided dice can be rearranged and rotated. One die has the numbers 0, 1, 2, 3, 4, and 5. The second die has the numbers 0, 1, 2, 6, 7, and 8. With this, any day of the month—from 1 to 31—can be displayed on the front of the calendar. The 6
can be rotated to be used as a 9
.
However, what if I wanted to display any number up to... 100? 365? 50287? How many 6-sided dice would I need then, and what numbers would be printed on their sides?
The challenge:
- Given a whole number input X, output the fewest possible 6-sided dice that are required to display all integers from 1 up to and including X.
- Each side of a die must contain exactly one integer, from 0 to 8 inclusive.
6
's may be used as9
's.- If not every side of every die needs to have a number on it, then those side(s) must have
0
. - Each line of the output should represent a die, e.g.:
Input: 4
Output:
0 0 1 2 3 4
Input: 6
Output:
1 2 3 4 5 6
Input: 9
Output:
0 1 2 3 4 5
0 0 0 6 7 8
Input: 31
Output:
0 1 2 3 4 5
0 1 2 6 7 8
Input: 35
Output:
0 1 2 3 4 5
0 1 2 3 6 7
0 0 0 0 0 8
- The output lines can be in any format, e.g.:
123456
1 2 3 4 5 6
1,2,3,4,5,6
[1, 2, 3, 4, 5, 6]
- Assume that all the dice are used for every number, using leading 0's if necessary. For instance, if X is 35, then
2
would be displayed as002
, because 3 dice are necessary. - The outputted numbers do not need to be in any particular order.
- There may be multiple solutions for X. You need only output one.
- Standard golfing rules apply.
05
or04
. \$\endgroup\$