How to generate all permutations of a list?
How to generate all permutations of a list?
How to generate all permutations of a list?
You want all permutations of each member of the powerset of the input. permSub(“abc”, “”) func permSub(input, perm) print perm if input = “” return for i = 0 to input.length-1 permSub(input[0..i]+input[i+1..input.length), perm+input[i] end end Where input[i..j] represents the sub string of input from i(inclusive) to j(exclusive), and + is string concatenation. Note that this … Read more
Thanks to those who helped! you guys are what keeps this community up, kudos! now for those who said I havent tried – Il make it clear as hell – you dont know shit. I tried for over 2 weeks before coming here, and then you guys are like “oh you havent tried, do u … Read more
Making a guess at what your current code does, here’s a proposal for an algorithm: nondeterministically pick a permutation of the vowels assign indices to the permutation use the standard tails trick to nondeterministically choose the appropriate number of elements from this list In code: import Data.List choose :: Int -> [a] -> [[a]] choose … Read more