Created
August 20, 2018 10:12
-
-
Save Announcement/a4601a2bc137d68fc7f1671bc4f73de6 to your computer and use it in GitHub Desktop.
any performance enhancements greatly appreciated
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
function * reorder (current, bucket) { | |
if (bucket.length === 0) yield current; | |
else if (bucket.length === 1) yield current.concat(bucket) | |
else if (bucket.length > 1) | |
for (let i = 0; i < bucket.length; i++) { | |
yield* reorder([...current, bucket[i]], [...bucket.slice(0, i), ...bucket.slice(i + 1)]) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment