188 days ago · Tech · hide · Fediverse post

The challenge Given a lowercase word, return every permutation of its letters in alphabetical order. Do not use built-in permutation libraries. Examples: permutations('the'); // → ['eht', 'eth', 'het', 'hte', 'teh', 'the'] permutations('a'); // → ['a'] This is a Codewars classic in the JavaScript track. The two stumbling blocks are generating the permutations from scratch and producing them alphabetically. Solution 1: recursion + dedup + sort The most direct version. Recurse to build, Set to dedupe, sort to order:

Commenting on Bubbles has been removed. Why? If you want to talk about this post, write to the author, use the comments on their blog if it has them, or reply with a "RE:" post on your own blog. Suggestions? feedback@bubbles.town