백준 1598번: 꼬리를 무는 숫자 나열 #Python

ColorlessDia·2024년 7월 29일

algorithm/baekjoon

목록 보기
253/836
def calc_coordinate(number):
    row = 0
    col = 0

    if number % 4 == 0:
        row = 4
        col = number // 4
    else:
        row = number % 4
        col = (number // 4) + 1

    return (row, col)

a, b = map(int, input().split())

a_row, a_col = calc_coordinate(a)
b_row, b_col = calc_coordinate(b)

print(abs(b_col - a_col) + abs(b_row - a_row))

0개의 댓글