• + 2 comments
    def reverseGame(n, k):
        if n %2 != 0 and k == (n-1)/2:
            z = n - 1
        elif k >= n/2:
            z = ((n - 1) - k) * 2
        else:
            z = 1+2*k
        return z