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

[백준/파이썬] 29823번 Pakirobot Manhattanis

by 현장 2024. 1. 18.

-Code

input()
n_s, w_e = 0, 0
for el in input():
    if el == "N":
        n_s += 1
    elif el == "S":
        n_s -= 1
    elif el == "W":
        w_e += 1
    else:
        w_e -= 1

print(abs(n_s) + abs(w_e))