Skip to content
This repository was archived by the owner on Feb 19, 2026. It is now read-only.
This repository was archived by the owner on Feb 19, 2026. It is now read-only.

New puzzle: next permutation in lexicographical order #7

Description

@TalSchuster
defsat(nx: List[int], x=[1, 2, 4, 3]): """Find the next permutation of a given list by lexicographical ordering."""importitertoolsassertlen(x) ==len(nx) andset(x) ==set(nx)
returnx<nxandall([list(perm) <=xorlist(perm) >=nxforperminlist(itertools.permutations(x))])
Reveal solution
defsol():
return [1, 3, 2, 4]
Reveal solution
defsol():
importitertoolsperms=sorted([list(p) forpinlist(itertools.permutations(x))])
returnperms[perms.index(x) +1]

Solvers, post your solutions in the comments using the following formatting:

<details><summary>Reveal solution</summary>
```python
def sol():
return "world" # replace with your solution
```
</details>

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions