Skip to content

Instantly share code, notes, and snippets.

@wolfgarbe
Last active April 19, 2018 12:10
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save wolfgarbe/8f2b7649542192235d233cead98b710c to your computer and use it in GitHub Desktop.
Save wolfgarbe/8f2b7649542192235d233cead98b710c to your computer and use it in GitHub Desktop.
Composition Generation
public void CompositionGeneration(string input, string composition=””)
{
for (int i=1;i<=input.Length;i++)
{
string part1 = input.Substring(0, i);
//recursion with the remainder of the string
if (part1.Length < input.Length)
CompositionGeneration(input.Substring(i),composition+part1+“ “);
//display composition
else Console.WriteLine(composition+part1);
}
}
CompositionGeneration("isit");
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment