백준 17487번: 타자 연습 #Python

ColorlessDia·2025년 1월 9일

algorithm/baekjoon

목록 보기
417/808
S = input()

L = list('qwertyasdfgzxcvb')
R = list('uiophjklnm')

left_key_count = 0
right_key_count = 0
special_key_count = 0

for s in S:
    char = s

    if char == ' ':
        special_key_count += 1
        continue
    
    if char.isupper():
        special_key_count += 1
        char = char.lower()
    
    if char in L:
        left_key_count += 1
    elif char in R:
        right_key_count += 1

while 0 < special_key_count:
    
    if left_key_count <= right_key_count:
        left_key_count += 1
    else:
        right_key_count += 1
    
    special_key_count -= 1

print(left_key_count, right_key_count)

0개의 댓글