Click here to Skip to main content
15,919,774 members
Home / Discussions / Algorithms
   

Algorithms

 
Questionall combinations from a set of numbers Pin
Tom Deketelaere24-Sep-07 4:26
professionalTom Deketelaere24-Sep-07 4:26 
AnswerRe: all combinations from a set of numbers Pin
Luc Pattyn24-Sep-07 6:27
sitebuilderLuc Pattyn24-Sep-07 6:27 
GeneralRe: all combinations from a set of numbers Pin
Hoss Fly24-Sep-07 15:34
Hoss Fly24-Sep-07 15:34 
GeneralRe: all combinations from a set of numbers Pin
cp987624-Sep-07 15:57
cp987624-Sep-07 15:57 
GeneralRe: all combinations from a set of numbers Pin
Hoss Fly24-Sep-07 16:37
Hoss Fly24-Sep-07 16:37 
GeneralRe: all combinations from a set of numbers Pin
Stephen Hewitt24-Sep-07 20:33
Stephen Hewitt24-Sep-07 20:33 
GeneralRe: all combinations from a set of numbers Pin
Luc Pattyn25-Sep-07 0:52
sitebuilderLuc Pattyn25-Sep-07 0:52 
AnswerRe: all combinations from a set of numbers Pin
kkadir24-Sep-07 10:27
kkadir24-Sep-07 10:27 
<br />
char[] harfler = new char[7];<br />
                harfler[0] = tb1.Text.ToCharArray()[0];<br />
                harfler[1] = tb2.Text.ToCharArray()[0];<br />
                harfler[2] = tb3.Text.ToCharArray()[0];<br />
                harfler[3] = tb4.Text.ToCharArray()[0];<br />
                harfler[4] = tb5.Text.ToCharArray()[0];<br />
                harfler[5] = tb6.Text.ToCharArray()[0];<br />
                harfler[6] = tb7.Text.ToCharArray()[0];<br />
<br />
                List<string> liste = new List<string>();<br />
<br />
                for (int i = 0; i < harfler.Length; i++)<br />
                {<br />
                    for (int j = (i + 1) % 7, x = 0; x < harfler.Length; x++)<br />
                    {<br />
                        if (i != j)<br />
                        {<br />
                            for (int k = (j + 1) % 7, y = 0; y < harfler.Length; y++)<br />
                            {<br />
                                if (k != i && k != j)<br />
                                {<br />
                                    liste.Add(harfler[i] + "" + harfler[j] + "" + harfler[k]);<br />
                                    for (int l = (k + 1) % 7, z = 0; z < harfler.Length; z++)<br />
                                    {<br />
                                        if (l != i && l != j && l != k)<br />
                                        {<br />
                                            liste.Add(harfler[i] + "" + harfler[j] + "" + harfler[k] + "" + harfler[l]);<br />
                                            for (int m = (l + 1) % 7, t = 0; t < harfler.Length; t++)<br />
                                            {<br />
                                                if (m != i && m != j && m != k && m != l)<br />
                                                {<br />
                                                    liste.Add(harfler[i] + "" + harfler[j] + "" + harfler[k] + "" + harfler[l] + "" + harfler[m]);<br />
                                                    for (int n = (m + 1) % 7, v = 0; v < harfler.Length; v++)<br />
                                                    {<br />
                                                        if (n != i && n != j && n != k && n != l && n != m)<br />
                                                        {<br />
                                                            liste.Add(harfler[i] + "" + harfler[j] + "" + harfler[k] + "" + harfler[l] + "" + harfler[m] + "" + harfler[n]);<br />
                                                            for (int o = (n + 1) % 7, q = 0; q < harfler.Length; q++)<br />
                                                            {<br />
                                                                if (o != i && o != j && o != k && o != l && o != m && o != n)<br />
                                                                {<br />
                                                                    liste.Add(harfler[i] + "" + harfler[j] + "" + harfler[k] + "" + harfler[l] + "" + harfler[m] + "" + harfler[n] + "" + harfler[o]);<br />
<br />
                                                                }<br />
<br />
                                                                o = (++o) % 7;<br />
                                                            }<br />
                                                        }<br />
<br />
                                                        n = (++n) % 7;<br />
                                                    }<br />
                                                }<br />
<br />
                                                m = (++m) % 7;<br />
                                            }<br />
                                        }<br />
<br />
                                        l = (++l) % 7;<br />
                                    }<br />
                                }<br />
<br />
                                k = (++k) % 7;<br />
                            }<br />
                        }<br />
<br />
                        j = (++j) % 7;<br />
                    }<br />
                }<br />


Surely it is not an efficient way but in a specisific project this has worked well for me. It combinates 7 letters and produce words at least with length 3 and at most length 7.

.:: Something is Wrong ::.

AnswerRe: all combinations from a set of numbers Pin
PIEBALDconsult24-Sep-07 17:14
mvePIEBALDconsult24-Sep-07 17:14 
AnswerRe: all combinations from a set of numbers Pin
Stephen Hewitt24-Sep-07 20:40
Stephen Hewitt24-Sep-07 20:40 
GeneralRe: all combinations from a set of numbers Pin
Stephen Hewitt25-Sep-07 22:23
Stephen Hewitt25-Sep-07 22:23 
AnswerRe: all combinations from a set of numbers [modified] Pin
Avi Farah5-Oct-07 9:29
Avi Farah5-Oct-07 9:29 
QuestionAssigning tasks problem Pin
Wjousts21-Sep-07 7:25
Wjousts21-Sep-07 7:25 
AnswerRe: Assigning tasks problem Pin
Shog921-Sep-07 8:17
sitebuilderShog921-Sep-07 8:17 
GeneralRe: Assigning tasks problem Pin
Wjousts21-Sep-07 8:22
Wjousts21-Sep-07 8:22 
QuestionNesting and Optimization Logic Process Pin
ruready51120-Sep-07 15:15
ruready51120-Sep-07 15:15 
AnswerRe: Nesting and Optimization Logic Process Pin
Hoss Fly20-Sep-07 20:30
Hoss Fly20-Sep-07 20:30 
GeneralRe: Nesting and Optimization Logic Process Pin
ruready51121-Sep-07 3:54
ruready51121-Sep-07 3:54 
GeneralRe: Nesting and Optimization Logic Process Pin
Hoss Fly21-Sep-07 14:04
Hoss Fly21-Sep-07 14:04 
AnswerRe: Nesting and Optimization Logic Process [modified] Pin
cp987621-Sep-07 19:43
cp987621-Sep-07 19:43 
GeneralRe: Nesting and Optimization Logic Process Pin
Hoss Fly21-Sep-07 20:46
Hoss Fly21-Sep-07 20:46 
GeneralRe: Nesting and Optimization Logic Process Pin
ruready51122-Sep-07 18:33
ruready51122-Sep-07 18:33 
GeneralRe: Nesting and Optimization Logic Process Pin
Hoss Fly23-Sep-07 4:30
Hoss Fly23-Sep-07 4:30 
GeneralRe: Nesting and Optimization Logic Process Pin
cp987622-Sep-07 21:38
cp987622-Sep-07 21:38 
QuestionCalculating work-hour-only time differences Pin
sushicw18-Sep-07 7:43
sushicw18-Sep-07 7:43 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.