A fictional alien species counts using bases other than 10, and represents digit values 10 through 35 with the uppercase letters A through Z (so A = 10, B = 11, ..., Z = 35).
Given a non-negative decimal integer n and a base b, write n in base b using this digit alphabet, with no leading zeros (except when n itself is 0, in which case the answer is just 0).
Line 1: two space-separated integers n and b.
A single string: n written in base b, most-significant digit first, using 0-9 then A-Z for digit values 10 and above.
Example 1
Input
255 16
Expected
FF
Explanation
255 in base 16 is FF (15*16 + 15 = 255).
Example 2
Input
0 7
Expected
0
Explanation
Zero is written as 0 regardless of base.
Ready to solve this?
Sign in to open the editor, run your code against the sample tests, and submit against the full test suite.
Sign in to solve →