관리 메뉴

솜씨좋은장씨

[BaekJoon] 4589번 : Gnome Sequencing (Python) 본문

Programming/코딩 1일 1문제

[BaekJoon] 4589번 : Gnome Sequencing (Python)

솜씨좋은장씨 2022. 7. 12. 12:48
728x90
반응형

코딩 1일 1문제! 오늘의 문제는 백준의 Gnome Sequencing 입니다.

 

4589번: Gnome Sequencing

In the book All Creatures of Mythology, gnomes are kind, bearded creatures, while goblins tend to be bossy and simple-minded. The goblins like to harass the gnomes by making them line up in groups of three, ordered by the length of their beards. The gnomes

www.acmicpc.net

👨🏻‍💻 코드 ( Solution )

def gnomes_is_ordered_or_not(gnomes):
    is_ordered = False
    order_check_list = []
    for idx in range(len(gnomes) - 1):
        check_num = gnomes[idx] - gnomes[idx+1]
        order_check_list.append(check_num < 0)
        
    if len(set(order_check_list)) == 1:
        is_ordered = True
        
    return is_ordered
        

def gnome_sequencing(gnomes_list):
    print("Gnomes:")
    for gnomes in gnomes_list:
        is_ordered = gnomes_is_ordered_or_not(gnomes)
        
        if is_ordered:
            print("Ordered")
        else:
            print("Unordered")

            
if __name__ == "__main__":
    gnomes_list = []
    
    N = int(input())
    
    for _ in range(N):
        gnomes = list(map(int, input().split()))
        gnomes_list.append(gnomes)
        
    gnome_sequencing(gnomes_list)
 

GitHub - SOMJANG/CODINGTEST_PRACTICE: 1일 1문제 since 2020.02.07

1일 1문제 since 2020.02.07. Contribute to SOMJANG/CODINGTEST_PRACTICE development by creating an account on GitHub.

github.com

Comments