Created
July 5, 2017 12:53
-
-
Save KarthikMAM/5d61c3c0abec9af5828f2c7567035725 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
m = { | |
'0': '_', | |
'1': '0', | |
'2': '1', | |
'3': '2', | |
'4': '3', | |
'5': '4', | |
'6': '5', | |
'7': '6', | |
'8': '7', | |
'9': '8' | |
} | |
for t in range(1, int(input()) + 1): | |
x = list(input()) | |
change_from = len(x) | |
for i in range(len(x) - 1, 0, -1): | |
if x[i] < x[i - 1]: | |
change_from = i | |
x[i - 1] = m[x[i - 1]] | |
print("case #%s: %s" % (t, int(''.join(x[:change_from] + ['9'] * (len(x) - change_from))))) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment