Skip to content

Instantly share code, notes, and snippets.

@MrMeison
Created June 1, 2018 09:05
Show Gist options
  • Save MrMeison/180f26c72ef5811362ecc909d1d95b93 to your computer and use it in GitHub Desktop.
Save MrMeison/180f26c72ef5811362ecc909d1d95b93 to your computer and use it in GitHub Desktop.
#Uses python3
import sys
def bigger_than(a, b):
return (a + b) > (b + a)
def find_biggest_index(a):
max_index = 0
for i in range(len(a)):
if bigger_than(a[i], a[max_index]):
max_index = i
return max_index
def largest_number(a):
answer = ""
while a:
biggest_index = find_biggest_index(a)
answer += a[biggest_index]
del(a[biggest_index])
return answer
if __name__ == '__main__':
a = [ "123", "124", "56", "90", "99", "990"]
print(largest_number(a))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment