Answer the question
In order to leave comments, you need to log in
How to get all one and two letter combinations in order from a word?
For example, there is a line You
need to get all possible combinations, such as:
String str = "program";
for (int i = 0; i < str.length()-1; i = i +2){
String strTemp = str.charAt(i)+""+str.charAt(i+1);
System.out.println(strTemp);
}
Answer the question
In order to leave comments, you need to log in
The simplest recurrence relation:
All layouts for the word "program" are, firstly, all layouts for "rogram" with the prefix "p-", secondly, all layouts for "gram" with the prefix "pr-". Well, special cases of a word from one letter and empty. It seems that with this approach it will be convenient to use StringBuffer
p-r-o-g-r-a-m (0)
pr-o-g-r-a-m (1)
p-ro-g-r-a-m
p-r-og-r-a-m
p-r-o-gr-a-m
p-r-o-g-ra-m
p-r-o-g-r-am
pr-og-r-a-m (2)
pr-o-gr-a-m
pr-o-g-ra-m
pr-o-g-r-am
p-ro-gr-a-m
p-ro-g-ra-m
p-ro-g-r-am
p-r-og-ra-m
p-r-og-r-am
p-r-o-gr-am
pr-og-ra-m (3)
pr-og-r-am
pr-o-gr-am
p-ro-gr-am
7 letters, if we represent this in bits as 1111111, if there is no "-" before the first letter, then we cut it off, it turns out 111111, let's say 0 is "-" before the letter, then we go through the options in a cycle from 0 to 63, for example: 110101 = pro-gr-am
000000 = program
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question