Base Reduction
Description:
Base reduction
Input
A positive integer:
0 < n < 1000000000
Output
The end result of the base reduction.
If it cannot be fully reduced (reduced down to a single-digit number), return -1.
Assume that if 150 conversions from base 11 take place in a row, the number cannot be fully reduced.
Description
Base reduction is a process where a number is inputted, repeatedly converted into another base, and then outputted if it cannot be reduced anymore. If it cannot be fully reduced, return -1.
During the base conversions, the number is converted from the lowest base it can be converted from into base 10. For example, 123 would be converted from base 4 to base 10, since base 4 is the lowest base that 123 can be in (123 base 3 is impossible; in base 3, there is no digit 3).
If the lowest possible base the number can be converted into is 10, convert the number from base 11 to base 10. For example, 53109 would be converted from base 11 to base 10, since base 10 is the lowest base it can be in.
In the end, you should get a number that cannot be reduced by this process (a single digit number).
Example
Starting with 5312:
5312 base 6 = 1196 base 10
1196 base 11 = 1557 base 10
1557 base 8 = 879 base 10
879 base 11 = 1054 base 10
1054 base 6 = 250 base 10
250 base 6 = 102 base 10
102 base 3 = 11 base 10
11 base 2 = 3 base 10
The output would be 3.
Similar Kata:
Stats:
Created | Dec 2, 2016 |
Published | Dec 2, 2016 |
Warriors Trained | 410 |
Total Skips | 8 |
Total Code Submissions | 875 |
Total Times Completed | 135 |
Python Completions | 135 |
Total Stars | 6 |
% of votes with a positive feedback rating | 89% of 55 |
Total "Very Satisfied" Votes | 46 |
Total "Somewhat Satisfied" Votes | 6 |
Total "Not Satisfied" Votes | 3 |
Total Rank Assessments | 5 |
Average Assessed Rank | 6 kyu |
Highest Assessed Rank | 6 kyu |
Lowest Assessed Rank | 6 kyu |