Iterate Base
Coding Problem Keys
Iterate Base
Problem Statement
Consider the following examples.
1. For the number representation 11, the least possible base is 2 and hence the least possible value is 3 in base 10.
2. For 17, the least possible base is 8 and the least possible value is 15 is base 10.
3. For 1729, the least possible base in 10 and the least possible value is 1729 in base 10.
The program must perform the successive base reductions as above and print the resulting final number as the output.
The face values for the symbols are given below.
0 → 0
1 → 1
2 → 2
...
9 → 9
A → 10
B → 11
C → 12
...
X → 33
Y → 34
Z → 35
Input Format
Output Format
The first line contains an integer representing the final number representation that results from iteratively performing base reductions in the manner illustrated above.Boundary Condition(s)
1 <= Length of N <= 5Example Input/Output 1
Input
53Output
Explanation
Example Input/Output 2
Input
BCDOutput
Explanation
Max Execution Time Limit: 500 millisecs
Solution
Programming Language: Python 3 Language
a=input()
b,a=str(int(a,ord(max(a))-(54 if max(a).isalpha() else 47))),0
while a!=b:
a=b
b=str(int(a,ord(max(a))-47))
print(a)
# Published By PKJCODERS
(Note: Incase If the code doesn't Pass the output kindly comment us with your feedback to help us improvise.)
Comments