Created
April 10, 2022 07:47
-
-
Save theabbie/4808350d51053fdc33242353116652a6 to your computer and use it in GitHub Desktop.
Double or one thing google codejam solution
This file contains hidden or 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
t = int(input()) | |
def getSmallest(word): | |
n = len(word) | |
if n == 1: | |
return word | |
nchunk = getSmallest(word[1:]) | |
return min(word[0] + nchunk, word[0] * 2 + nchunk) | |
for tt in range(1, t + 1): | |
word = input() | |
print("Case #{}: {}".format(tt, getSmallest(word))) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment