BOJ - 3041 - N-퍼즐

Updated:

def solution():
    ret = 0
    for i in range(4):
        Puzzle = list(input())
        for j in range(4):
            if Puzzle[j] != '.':
                ret += abs((ord(Puzzle[j]) - ord('A')) % 4 - j)
                ret += abs((ord(Puzzle[j]) - ord('A')) // 4 - i)
    print(ret)

solution()

https://www.acmicpc.net/problem/3041

Categories:

Updated:

Leave a comment