Every permutation of the alphabet up to 29 characters?

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

    just off the top of my head (PHP).

    $index = 0;
    
    while(1) {
       $output_string = '';
       $base_26 = (string)base_convert($index, 10, 26);
       if (strlen($base_26) > 29) break;
       for ($i = 0; $i < strlen($base_26); $i++) {
          $output_string .= chr(65 + base_convert($base_26[$i], 26, 10));
       }
       $index++;
       echo $output_string;
    }
    

提交回复
热议问题