관리 메뉴

솜씨좋은장씨

[BaekJoon] 5300번 : Fill the Rowboats! (Python) 본문

Programming/코딩 1일 1문제

[BaekJoon] 5300번 : Fill the Rowboats! (Python)

솜씨좋은장씨 2023. 1. 15. 18:28
728x90
반응형

코딩 1일 1문제! 오늘의 문제는 백준의 Fill the Rowboats! 입니다.

 

5300번: Fill the Rowboats!

The output will be the number of each pirate separated by spaces, with the word ”Go!” after every 6th pirate, and after the last pirate.

www.acmicpc.net

👨🏻‍💻 코드 ( Solution )

def fill_the_rowboats(number):
    answer_list = []
    
    number_list = list(range(1, number + 1))
    
    slice_num = len(number_list) // 6 if len(number_list) % 6 == 0 else len(number_list) // 6 + 1
    
    for slice_idx in range(slice_num):
        slice_list = list(map(str, number_list[6 * slice_idx: 6 * (slice_idx + 1)]))
        
        slice_list.append("Go!")
        
        answer_list.append(" ".join(slice_list))
        
    return " ".join(answer_list)
        
    
if __name__ == "__main__":
    number = int(input())
    
    print(fill_the_rowboats(number=number))
 

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