Quantcast
Viewing latest article 16
Browse Latest Browse All 186

Splitting a string into substrings of length 1 and 2

There is already a thread on how to split a string into equal sized chunks.I'm wanting to split a string into sets of substrings of length 1 and 2.For example, if I have the string "123456", my list would include elements such as{12,3,4,56},{1,2,3,45,6},and {1,2,34,56}.

I found this little bit of Python code, but 1) I don't know how to translate it into Mathematica code and 2) it gives you strings with a bunch of extra commas (because it's basically just distributing n commas through the string in different ways).

I suspect there is a very simple way of doing this in Mathematica.


Viewing latest article 16
Browse Latest Browse All 186

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>