Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- def sortStringByLength(str1, str2):
- str1Len = len(str1)
- str2Len = len(str2)
- if(str1Len > str2Len):
- return [str1, str2]
- else:
- return [str2, str1]
- def getStringToLength(str1, length):
- if(len(str1)==length):
- return str1
- else:
- return str1 + str1[-1] * (length - len(str1))
- def getStringVal(pStr1, pStr2):
- l = sortStringByLength(pStr1, pStr2)
- val = int(l[0])
- val2 = int(getStringToLength(l[1], len(l[0])))
- if(val > val2):
- return l[0]
- else:
- return l[1]
- def getNextMaxString(strings):
- maxString = strings[0]
- for otherString in strings:
- if(maxString!=otherString):
- maxString = getStringVal(maxString, otherString)
- return maxString
- def getMaxStrings(strings):
- mstrings = []
- while(len(strings)>0):
- tStr = getNextMaxString(strings)
- strings.remove(tStr)
- mstrings.append(tStr)
- res = ""
- for s in mstrings:
- res = res +" "+ s
- return res
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement