Created
February 16, 2026 09:40
-
-
Save goofballLogic/02ffef98a9fce78f4039581c57c1e472 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| const swap = (xs, n, i) => | |
| xs.fill( | |
| xs.splice(i+1, 1, n)[0], | |
| i, | |
| i+1 | |
| ) | |
| ; | |
| const chase = (xs, n, i) => | |
| i === xs.length - 1 | |
| ? xs | |
| : chase( | |
| swap(xs, n, i), | |
| n, | |
| ++i | |
| ) | |
| ; | |
| const chaseIfN = (xs, n, i) => | |
| xs[i] === n | |
| ? chase(xs, n, i) | |
| : xs | |
| ; | |
| const moveNums = (xs, n, i = 0) => | |
| i === xs.length ? | |
| xs : | |
| moveNums( | |
| chaseIfN(xs, n, i), | |
| n, | |
| ++i | |
| ) | |
| ; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment