Every permutation of the alphabet up to 29 characters?

后端 未结 13 1347
攒了一身酷
攒了一身酷 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:21

    Even if you could store this on disk, like thirydot pointed out, you'd run out of time doing this.

    Just generating (and not storing) all the 6-letter possiblilies took 24 seconds on my computer:

    $ time perl letters.pl
    
    real    0m24.837s
    user    0m24.765s
    sys     0m0.030s
    

    Which is 7.7X10^-8s per word, That means it would take 8.4x10^33s or 2.6x10^26 years to do this.

    You need to think more about your algorithm.

提交回复
热议问题