본문 바로가기
프로그래밍 문제/[Python] CheckIO

[CheckIO/Scientific Expedition] Beat The Previous

by UltraLowTemp-Physics 2024. 3. 24.
728x90

1. Problem: https://py.checkio.org/en/mission/beat-the-previous/
2. My solution

def beat_previous(digits: str) -> list[int]:
    # your code here
    dummy_list = []
    list_digits = list(digits)
    dummy_number = "0"
    for index in range(len(list_digits)):
        if index == 0:
            dummy_list.append(int(list_digits[index]))
        else:
            dummy_number+=list_digits[index]
            if int(dummy_number) <= dummy_list[-1]: continue
            else: 
                dummy_list.append(int(dummy_number))
                dummy_number = ""
   
    return dummy_list
728x90

댓글