def calculate_manhattan_dist(idx, value, n):

    """calculate the manhattan distance of a tile"""

    ### STUDENT CODE GOES HERE ###
    if not value:
        return 0

    cur_row_idx = idx // n + 1
    cur_col_idx = idx % n + 1

    goal_row_idx = value // n + 1
    goal_col_idx = value % n + 1

    return abs(cur_row_idx - goal_row_idx) + abs(cur_col_idx - goal_col_idx)