Last active
April 19, 2018 12:10
-
-
Save wolfgarbe/8f2b7649542192235d233cead98b710c to your computer and use it in GitHub Desktop.
Composition Generation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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