Every permutation of the alphabet up to 29 characters?

后端 未结 13 1538
攒了一身酷
攒了一身酷 2021-02-11 01:23

I\'m attempting to write a program that will generate a text file with every possible permutation of the alphabet from one character up to twenty-nine characters. I\'ve chosen 2

13条回答
  •  萌比男神i
    2021-02-11 02:19

    Obviously, the outer for loop is for the number of characters in your word. Then, you just create strings with that length. For length 5, you start with "AAAAA", then "AAAAB", "AAAAC".

    Once you hit "Z", you go back and move the character to your left one up, i.e. "AAAAZ" becomes "AAABA", and "AAAZZ" becomes "AABAA". Once you hit "ZZZZZ", you're done with the inner loop, and the outer loop will then start with "AAAAAA".

提交回复
热议问题