文字と数字を生成する方法を教えてください
26 個の文字 {a-Z} と 10 個の数字 {0-9} があります
8 ビット文字を生成したい場合は、大文字と小文字が区別されます
など。配置は (26 26 10 ) 8 乗 = 218340105584896、これら 218 兆
ですが、{a1b2cc90、この文字は cc に 2 回表示されます}
のように、2 つ以上の同一のものが隣接することはできません。 PHPで生成されるのでしょうか?
単一のテキストデータを生成できない場合は、複数の部分に分割する必要があります...
-----解決策のアイデア----------- ---- ------
これはどういう意味ですか?
$d = str_split('abcd');<br />print_r(array_map('join', f(4, $d)));<br /><br />function f($n, $d) {<br /> $t = array_chunk($d, 1);<br /> if($n > 2) $t = f($n-1, $d);<br /> foreach($t as $x)<br /> foreach(array_chunk($d, 1) as $y) {<br /> if(end($x) != end($y)) $r[] = array_merge($x, $y);<br /> }<br /> return $r;<br />}
Array<br />(<br /> [0] => abab<br /> [1] => abac<br /> [2] => abad<br /> [3] => abca<br /> [4] => abcb<br /> [5] => abcd<br /> [6] => abda<br /> [7] => abdb<br /> [8] => abdc<br /> [9] => acab<br /> [10] => acac<br /> [11] => acad<br /> [12] => acba<br /> [13] => acbc<br /> [14] => acbd<br /> [15] => acda<br /> [16] => acdb<br /> [17] => acdc<br /> [18] => adab<br /> [19] => adac<br /> [20] => adad<br /> [21] => adba<br /> [22] => adbc<br /> [23] => adbd<br /> [24] => adca<br /> [25] => adcb<br /> [26] => adcd<br /> [27] => baba<br /> [28] => babc<br /> [29] => babd<br /> [30] => baca<br /> [31] => bacb<br /> [32] => bacd<br /> [33] => bada<br /> [34] => badb<br /> [35] => badc<br /> [36] => bcab<br /> [37] => bcac<br /> [38] => bcad<br /> [39] => bcba<br /> [40] => bcbc<br /> [41] => bcbd<br /> [42] => bcda<br /> [43] => bcdb<br /> [44] => bcdc<br /> [45] => bdab<br /> [46] => bdac<br /> [47] => bdad<br /> [48] => bdba<br /> [49] => bdbc<br /> [50] => bdbd<br /> [51] => bdca<br /> [52] => bdcb<br /> [53] => bdcd<br /> [54] => caba<br /> [55] => cabc<br /> [56] => cabd<br /> [57] => caca<br /> [58] => cacb<br /> [59] => cacd<br /> [60] => cada<br /> [61] => cadb<br /> [62] => cadc<br /> [63] => cbab<br /> [64] => cbac<br /> [65] => cbad<br /> [66] => cbca<br /> [67] => cbcb<br /> [68] => cbcd<br /> [69] => cbda<br /> [70] => cbdb<br /> [71] => cbdc<br /> [72] => cdab<br /> [73] => cdac<br /> [74] => cdad<br /> [75] => cdba<br /> [76] => cdbc<br /> [77] => cdbd<br /> [78] => cdca<br /> [79] => cdcb<br /> [80] => cdcd<br /> [81] => daba<br /> [82] => dabc<br /> [83] => dabd<br /> [84] => daca<br /> [85] => dacb<br /> [86] => dacd<br /> [87] => dada<br /> [88] => dadb<br /> [89] => dadc<br /> [90] => dbab<br /> [91] => dbac<br /> [92] => dbad<br /> [93] => dbca<br /> [94] => dbcb<br /> [95] => dbcd<br /> [96] => dbda<br /> [97] => dbdb<br /> [98] => dbdc<br /> [99] => dcab<br /> [100] => dcac<br /> [101] => dcad<br /> [102] => dcba<br /> [103] => dcbc<br /> [104] => dcbd<br /> [105] => dcda<br /> [106] => dcdb<br /> [107] => dcdc<br />)<br /><br />