Created
June 1, 2018 09:05
-
-
Save MrMeison/180f26c72ef5811362ecc909d1d95b93 to your computer and use it in GitHub Desktop.
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
#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