def METHOD_NAME(i: int, n: int, tile_sz: int, total_sz: int) -> int:
    if 0 <= i < n - 1:  # not edge tile
        return tile_sz
    elif i == n - 1:    # edge tile
        return total_sz - (i*tile_sz)
    else:               # out of index case
        raise IndexError("Index ({},{}) is out of range".format(*idx))