Every permutation of the alphabet up to 29 characters?

后端 未结 13 1306
攒了一身酷
攒了一身酷 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条回答
  •  无人及你
    2021-02-11 02:17

    Here is a permutation generator written in java http://www.merriampark.com/perm.htm.

    However as he mentions

      //-----------------------------------------------------------
      // Constructor. WARNING: Don't make n too large.
      // Recall that the number of permutations is n!
      // which can be very large, even when n is as small as 20 --
      // 20! = 2,432,902,008,176,640,000 and
      // 21! is too big to fit into a Java long, which is
      // why we use BigInteger instead.
      //----------------------------------------------------------
    

    Since your n is 29, you will be waiting a long, long time. It is too large, as EboMike is trying to tell you in his comments.

提交回复
热议问题