Note that there are some explanatory texts on larger screens.

plurals
  1. POC# Char permutation with repetition on large set of chars
    text
    copied!<p>Hello Im trying to get all possible combinations with repetitions of given char array. Char array consists of alphabet letters(only lower) and I need to generate strings with length of 30 or more chars.</p> <p>I tried with method of many for-loops,but when I try to get all combinations of char in char array with length of string more then 5 I get out of Memory Exception.</p> <p>So I created similar Method that takes only first 200000 strings,then next 2000000 and so on this was proven sucessfull but only with smaller length strings.</p> <p>This was my method with length of 7 chars:</p> <pre><code>public static int Progress = 0; public static ArrayList CreateRngUrl7() { ArrayList AllCombos = new ArrayList(); int passed = 0; int Too = Progress + 200000; char[] alpha = "ABCDEFGHIJKLMNOPQRSTUVWXYZ".ToLower().ToCharArray(); for (int i = 0; i &lt; alpha.Length; i++) for (int i1 = 0; i1 &lt; alpha.Length; i1++) for (int i2 = 0; i2 &lt; alpha.Length; i2++) for (int i3 = 0; i3 &lt; alpha.Length; i3++) for (int i4 = 0; i4 &lt; alpha.Length; i4++) for (int i5 = 0; i5 &lt; alpha.Length; i5++) for (int i6 = 0; i6 &lt; alpha.Length; i6++) { if (passed &gt; (Too - 200000) &amp;&amp; passed &lt; Too) { string word = new string(new char[] { alpha[i], alpha[i1], alpha[i2], alpha[i3], alpha[i4], alpha[i5],alpha[i6] }); AllCombos.Add(word); } passed++; } if (Too &gt;= passed) { MessageBox.Show("All combinations of RNG7 were returned"); } Progress = Too; return AllCombos; } </code></pre> <p>I tried adding 30 for-loops with in way described above so i Would get strings with lenghts of 30 but application just hangs.Is there any better way to do this? All answers would be much appreciated. Thank you in advance!</p> <p><strong>Can someone please just post method how it is done with larger legth strings I just want to see an example? I don't have to store that data,I just need to compare it with something and release it from memory. I used alphabet for example I don't need whole alphabet.Question was not how long it would take or how much combinations would it be!!!!!</strong></p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload