You are viewing a single comment's thread. Return to all comments →
def biggerIsGreater(w): alphabets = list(w) alphabets_copy = alphabets.copy() for i in range(-2,-len(alphabets)-1, -1): if alphabets[i] < alphabets[i+1]: for j in range(-1,i,-1): if alphabets[i] < alphabets[j]: alphabets[i], alphabets[j] = alphabets[j], alphabets[i] break alphabets[i+1:] = sorted(alphabets[i+1:]) break if alphabets_copy == alphabets: return "no answer" else: return ''.join(alphabets)
Seems like cookies are disabled on this browser, please enable them to open this website
Bigger is Greater
You are viewing a single comment's thread. Return to all comments →