백준 2929번: 머신 코드 #Python

ColorlessDia·2025년 3월 21일

algorithm/baekjoon

목록 보기
488/813
def calc_NOP_count(string):
    length = len(string)

    if length % 4 == 0:
        return 0
    
    return 4 - (length % 4)

S = input()

temp = S[0]
NOP_count = 0

for i in range(1, len(S)):
    char = S[i]

    if char.islower():
        temp += char
    else:
        NOP_count += calc_NOP_count(temp)
        temp = char

print(NOP_count)

0개의 댓글