문제

정은경·2020년 3월 26일
0

ha = ['3','34','1','13','5']
print(ha.sort)
print(ha)
print(max(ha))

def solution(numbers):
    count = len(str(max(numbers)))
    nums = [str(x) for x in numbers]
    nums.sort()

    rlt = ''
    left = ''
    for i in range(1, count+1):
        sub_num = [x for x in nums if len(x) == i]
        print(sub_num, nums)
        while sub_num:
            temp = sub_num[-1]
            if temp == '0':
                left += temp
                sub_num.remove(temp)
                nums.remove(temp)
            else:
                if sub_num[-1] == nums[-1]:
                    rlt += temp
                    sub_num.remove(temp)
                    nums.remove(temp)
                else:
                    if sub_num[-1][-1] > nums[-1][-1]:
                        temp = sub_num[-1]
                        rlt += temp
                        sub_num.remove(temp)
                        nums.remove(temp)
                    else:
                        temp = nums[-1]
                        rlt += temp
                        nums.remove(temp)

    # print(sub_num, nums)
    rlt += left
    return rlt

num = [3, 30, 34, 5, 9]
print(solution(num))
profile
#의식의흐름 #순간순간 #생각의스냅샷

0개의 댓글