Given a string representing a number and the base that number is in, shift each positional value upward, wrapping back to zero if the value cannot increase. You will never be provided invalid input, nor a base larger than 36.
For example, you may be provided ['5f6', '16']
, which represents the number 1526 in base 16. The expected output in that case would be '607'
(1543 in base 16).
Input
- program: separate lines from STDIN:
'5f6\n16'
- function: a tuple or array:
f(['5f6', '16'])
orf(['5f6', 16])
- function: two arguments
f('5f6', '16')
orf('5f6', 16)
Output
- program: to STDOUT:
607
- function: returned as a string:
'607'
Test cases
['5f6', '16']
'607'
['abc', '36']
'bcd'
['1', '1'] or ['0', '1']
'1' or '0'
['9540', '10']
'0651' or '651'
['001', '2']
'110'
"5f6"\n16
? \$\endgroup\$['999', '10']
? \$\endgroup\$'000'
\$\endgroup\$