one-line-wonders
one-line-wonders copied to clipboard
Combinations
You are given an array with random integers. Design an algorithm that returns a list of arrays with all the possible combinations of the numbers in the array. This means if the input is [1,2,3], the output will be [[1],[2],[3],[12],[13],[23],[123]].
Some solutions might be faster than others but speed does not matter.
Solved it Please check if changes let me know https://github.com/wzhouwzhou/one-line-wonders/pull/383
Please see my comments
Solved it in Javascript. This kind of combination is known as a power set and I found more information about it on wikipedia.
It's very inefficient but that's usually the case with complex javascript one-liners. 😄