Skip to content

Instantly share code, notes, and snippets.

@Zedmor
Created October 9, 2016 02:06
Show Gist options
  • Save Zedmor/4dfc48ae70a40a541382fdd23e5863f5 to your computer and use it in GitHub Desktop.
Save Zedmor/4dfc48ae70a40a541382fdd23e5863f5 to your computer and use it in GitHub Desktop.
#Uses python3
import sys
def largest_number(a):
#write your code here
def numCmp(a,b):
'''
:param a:
:param b: a and b - strings of int
:return: if a >= b: true else false
'''
acp,bcp = list(a),list(b)
minlen = min(len(a),len(b))
for i in range(minlen):
topa= acp.pop(0)
topb = bcp.pop(0)
if int(topa) != int(topb): return int(topa) > int(topb)
return len(a)<=len(b)
def qsort(inlist):
if inlist == []:
return []
else:
pivot = inlist[0]
lesser = qsort([x for x in inlist[1:] if numCmp(x,pivot)])
greater = qsort([x for x in inlist[1:] if not(numCmp(x,pivot))])
return lesser + [pivot] + greater
return qsort(a)
if __name__ == '__main__':
#input = sys.stdin.read()
# input = '100 2 8 2 3 6 4 1 1 10 6 3 3 6 1 3 8 4 6 1 10 8 4 10 4 1 3 2 3 2 6 1 5 2 9 8 5 10 8 7 9 6 4 2 6 3 8 8 9 8 2 9 10 3 10 7 5 7 1 7 5 1 4 7 6 1 10 5 4 8 4 2 7 8 1 1 7 4 1 1 9 8 6 5 9 9 3 7 6 3 10 8 10 7 2 5 1 1 9 9 5'
#input = '2 10 1'
input = '5 9 99 989 969 0 948 6'
data = input.split()
a = data[1:]
print(''.join(largest_number(a)))
# print(largest_number(a))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment