1

I am trying to save every combination of AAAAAAAA - ZZZZZZZZ to a text file. So far after having many many errors, I have got almost nowhere. I could post my code if needed, but it doesn't work or get near the wanted outcome.

So I was wondering how to do this in c#. My method at the moment is beyond repair, I will have to start all again in order to fix this.

As the output I would like something along the lines of

AAAAAAAA, AAAAAAAB, AAAAAAAC ... ZZZZZZZX, ZZZZZZZY, ZZZZZZZZ

Thanks in advance for any help.

Blorgbeard
  • 101,031
  • 48
  • 228
  • 272
Connor B.
  • 21
  • 4

2 Answers2

6

This is a basic combinatorics question:
You want to write a string of 8 characters.
Each character can be a letter between A-Z (26 options), therefore, there are 26^8 combinations: 26*26*26*...26.
That is 208827064576 combinations.
Each combination is 10 bytes (8 for string, then \r\n), which is a total of 1944.85 GB.
Are you sure you want to write it to a file?

Itsik
  • 3,920
  • 1
  • 25
  • 37
3

This will take about 1.5-2 Terabytes. That's a huge text file to start with, probably impractical.

Secondly, the way to do this simply is to have 8 nested loops, each running through A to Z, then concatenate the string inside the inner loop, appending to the data store each time.

Bradley Thomas
  • 4,060
  • 6
  • 33
  • 55
  • I need to write it to a file, as it needs to be read by another program. The size is a small problem as I only need it for 2-3 days. I have enough free space until then. Size aside, thanks for this answer, while this isn't the method I used (the one in the comment section of OP) this is how I originally intended to do this, after reading your question I realised my mistake and fixed it. – Connor B. Apr 07 '16 at 21:03
  • Why does it need to be read by another program? Why can't you adjust the other program to simply generate the string on the fly from the (base 26) number? – Bradley Thomas Apr 08 '16 at 04:18
  • unfortunately the other program is not written by me, and is also not open source. There are alternatives, but none are as powerful as the one I wish to use. The way I decided to do was make a 40GB chunk of each block, use that, then delete the file and generate the next chunk, rinse and repeat until I have ran all possibilities. – Connor B. Apr 12 '16 at 22:33
  • I'm curious what your program's intended use/purpose is? – Bradley Thomas Apr 14 '16 at 16:48