본문 바로가기
Problem Solving/SWEA

[SWEA|파이썬] 1225. [S/W 문제해결 기본] 7일차 - 암호생성기 (D3)

by 청량리 물냉면 2023. 5. 10.
반응형
문제

https://tinyurl.com/2olv5d2z

 

SW Expert Academy

SW 프로그래밍 역량 강화에 도움이 되는 다양한 학습 컨텐츠를 확인하세요!

swexpertacademy.com

 

 

🐍파이썬
T = 10
for test_case in range(1, T + 1):
    tc = int(input())
    data = list(map(int, input().split()))
    i = 1
    while True:
        if i > 5:
            i = 1
        data.append(data.pop(0)-i)
        if data[7] <= 0:
            data[7] = 0
            break
        i += 1
    print("#{} {} {} {} {} {} {} {} {}".format(tc, *data))

T = 10
for test_case in range(1, T + 1):
    _ = int(input())
    arr = [i for i in list(map(int, input().split()))]
    i = 1
    while True:
        a = arr.pop(0)-i
        if a <= 0:
            arr.append(0)
            break
        else:
            arr.append(a)
        i += 1
        if i > 5:
            i = 1
    print("#{} {}".format(test_case, ' '.join(map(str, arr))))
반응형