Skip to content

Instantly share code, notes, and snippets.

@fabriziogiordano
Created March 12, 2017 19:46
Show Gist options
  • Select an option

  • Save fabriziogiordano/3135b84cccbb0ca6cebf24bb04e92ace to your computer and use it in GitHub Desktop.

Select an option

Save fabriziogiordano/3135b84cccbb0ca6cebf24bb04e92ace to your computer and use it in GitHub Desktop.
combinatios or permutation or something
string = ['abcdef']
result => [
['abcdef'],
['a', 'bcdef'],
['ab', 'cdef'],
['abc', 'def'],
['abcd', 'ef'],
['abcde', 'f'],
['a', 'b', 'cdef'],
['a', 'bc', 'def'],
['a', 'bcd', 'ef'],
['a', 'bcde', 'f'],
['ab', 'c', 'def'],
['ab', 'cd', 'ef'],
['ab', 'cde', 'f'],
['abc', 'd', 'ef'],
['abc', 'de', 'f'],
['abcd', 'e', 'f'],
['a', 'b', 'c', 'def'],
['a', 'b', 'cd', 'ef'],
['a', 'b', 'cde', 'f'],
['a', 'bc', 'd', 'ef'],
['a', 'bc', 'de', 'f'],
['a', 'bcd', 'e', 'f'],
['ab', 'c', 'd', 'ef'],
['ab', 'c', 'de', 'f'],
['ab', 'cd', 'e', 'f'],
['abc', 'd', 'e', 'f'],
['a', 'b', 'c', 'd', 'ef'],
['a', 'b', 'c', 'de', 'f'],
['a', 'b', 'cd', 'e', 'f'],
['a', 'bc', 'd', 'e', 'f'],
['ab', 'c', 'd', 'e', 'f'],
['a', 'b', 'c', 'd', 'e', 'f']
];
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment