This is a code golf version of a similar question I asked on stack earlier but thought it'd be an interesting puzzle.
Given a string of length 10 which represents a base 36 number, increment it by one and return the resulting string.
This means the strings will only contain digits from
9 and letters from
Base 36 works as follows:
The right most digit is incremented, first by using
0000000000 > 9 iterations > 0000000009
and after that
z is used:
000000000a > 25 iterations > 000000000z
z needs to be incremented it loops back to zero and the digit to its left is incremented:
- You may use upper case or lower case letters.
- You may not drop leading zeros. Both input and output are strings of length 10.
- You do not need to handle
"0000000000" -> "0000000001" "0000000009" -> "000000000a" "000000000z" -> "0000000010" "123456zzzz" -> "1234570000" "00codegolf" -> "00codegolg"
"0zzzzzzzzz"(modify the most signficant digit) as a test case. It tripped up my C solution because of an off-by-one-error. \$\endgroup\$