본문 바로가기
Beakjoon&프로그래머스/파이썬

[백준/파이썬] 8826번 Spacer

by 현장 2024. 2. 27.

-Code

for _ in range(int(input())):
    n = input()
    direction = input()
    print(
        abs(direction.count('W') - direction.count('E')) +
        abs(direction.count('N') - direction.count('S'))
    )