[Python] Value by Value
We build the permutation value by value with the same algorithm as if we are writing the k-th permutation with no restrictions.want stores the parity of the nex
We build the permutation value by value with the same algorithm as if we are writing the k-th permutation with no restrictions.

`want` stores the parity of the next desired digit. Except when N is even, the very first digit could be odd or even.

`ways` stores the number of permutations given we select value `v` next.

# Code
```python3 []
class Solution:
    def permute(self, N, K):
        ans = []
        vals = list(range(1, N + 1))
        want = 1

        for t in range(N):
            ways = factorial(N - 1 - t >> 1) * factorial(N - t >> 1)

            for i, v in enumerate(vals):
                if v % 2 != want and (t or N % 2):
                    continue
                if K <= ways:
                    break
                K -= ways
            else:
                return []

            ans.append(vals.pop(i))
            want = ans[-1] & 1 ^ 1

        return ans
```
['Python3']