def two_opt_swap(r: list, i: int, k: int) ->list:
    """Reverses items `i`:`k` in the list `r`
    https://en.wikipedia.org/wiki/2-opt."""
    out = r.copy()
    out[i:k + 1] = out[k:i - 1:-1]
    return out
