<?php
// Returns the total number of $count-length strings generatable from $letters.
function getPermCount($letters, $count)
{
$result = 1;
// k characters from a set of n has n!/(n-k)! possible combinations
for($i = strlen($letters) - $count + 1; $i <= strlen($letters); $i++) {
$result *= $i;
}
return $result;
}
// Decodes $index to a $count-length string from $letters, no repeat chars.
function getPerm($letters, $count, $index)
{
$result = array();
for($i = 0; $i < $count; $i++)
{
$pos = $index % strlen($letters);
$result[] = $letters[$pos];
$index = ($index-$pos)/strlen($letters);
$letters = substr($letters, 0, $pos) . substr($letters, $pos+1);
}
sort($result);
return implode("", $result);
}
$r = array();
//$letters = 'abcdefghijklm';
$letters = 'abcdefgh';
$len = strlen($letters);
for ($c = 1; $c <= $len; $c++)
for($i = 0; $i < getPermCount($letters, $c); $i++)
$r[] = getPerm($letters, $c, $i);
print_r(array_unique($r, SORT_REGULAR));
- Output for 5.2.9 - 5.2.17, 5.3.0 - 5.3.29, 5.4.0 - 5.4.45, 5.5.0 - 5.5.38, 5.6.0 - 5.6.40, 7.0.0 - 7.0.33, 7.1.0 - 7.1.33, 7.2.0 - 7.2.33, 7.3.0 - 7.3.33, 7.4.0 - 7.4.33, 8.0.0 - 8.0.30, 8.1.0 - 8.1.28, 8.2.0 - 8.2.18, 8.3.0 - 8.3.6
- Array
(
[0] => a
[1] => b
[2] => c
[3] => d
[4] => e
[5] => f
[6] => g
[7] => h
[8] => ab
[10] => ac
[11] => ad
[12] => ae
[13] => af
[14] => ag
[15] => ah
[17] => bc
[19] => bd
[20] => be
[21] => bf
[22] => bg
[23] => bh
[26] => cd
[28] => ce
[29] => cf
[30] => cg
[31] => ch
[35] => de
[37] => df
[38] => dg
[39] => dh
[44] => ef
[46] => eg
[47] => eh
[53] => fg
[55] => fh
[62] => gh
[64] => abc
[67] => abd
[68] => abe
[69] => abf
[70] => abg
[71] => abh
[82] => acd
[84] => ace
[85] => acf
[86] => acg
[87] => ach
[91] => ade
[93] => adf
[94] => adg
[95] => adh
[100] => aef
[102] => aeg
[103] => aeh
[109] => afg
[111] => afh
[118] => agh
[129] => bcd
[132] => bce
[133] => bcf
[134] => bcg
[135] => bch
[147] => bde
[149] => bdf
[150] => bdg
[151] => bdh
[156] => bef
[158] => beg
[159] => beh
[165] => bfg
[167] => bfh
[174] => bgh
[194] => cde
[197] => cdf
[198] => cdg
[199] => cdh
[212] => cef
[214] => ceg
[215] => ceh
[221] => cfg
[223] => cfh
[230] => cgh
[259] => def
[262] => deg
[263] => deh
[277] => dfg
[279] => dfh
[286] => dgh
[324] => efg
[327] => efh
[342] => egh
[389] => fgh
[400] => abcd
[404] => abce
[405] => abcf
[406] => abcg
[407] => abch
[427] => abde
[429] => abdf
[430] => abdg
[431] => abdh
[436] => abef
[438] => abeg
[439] => abeh
[445] => abfg
[447] => abfh
[454] => abgh
[530] => acde
[533] => acdf
[534] => acdg
[535] => acdh
[548] => acef
[550] => aceg
[551] => aceh
[557] => acfg
[559] => acfh
[566] => acgh
[595] => adef
[598] => adeg
[599] => adeh
[613] => adfg
[615] => adfh
[622] => adgh
[660] => aefg
[663] => aefh
[678] => aegh
[725] => afgh
[801] => bcde
[805] => bcdf
[806] => bcdg
[807] => bcdh
[828] => bcef
[830] => bceg
[831] => bceh
[837] => bcfg
[839] => bcfh
[846] => bcgh
[931] => bdef
[934] => bdeg
[935] => bdeh
[949] => bdfg
[951] => bdfh
[958] => bdgh
[996] => befg
[999] => befh
[1014] => begh
[1061] => bfgh
[1202] => cdef
[1206] => cdeg
[1207] => cdeh
[1229] => cdfg
[1231] => cdfh
[1238] => cdgh
[1332] => cefg
[1335] => cefh
[1350] => cegh
[1397] => cfgh
[1603] => defg
[1607] => defh
[1630] => degh
[1733] => dfgh
[2004] => efgh
[2080] => abcde
[2085] => abcdf
[2086] => abcdg
[2087] => abcdh
[2116] => abcef
[2118] => abceg
[2119] => abceh
[2125] => abcfg
[2127] => abcfh
[2134] => abcgh
[2275] => abdef
[2278] => abdeg
[2279] => abdeh
[2293] => abdfg
[2295] => abdfh
[2302] => abdgh
[2340] => abefg
[2343] => abefh
[2358] => abegh
[2405] => abfgh
[2882] => acdef
[2886] => acdeg
[2887] => acdeh
[2909] => acdfg
[2911] => acdfh
[2918] => acdgh
[3012] => acefg
[3015] => acefh
[3030] => acegh
[3077] => acfgh
[3283] => adefg
[3287] => adefh
[3310] => adegh
[3413] => adfgh
[3684] => aefgh
[4161] => bcdef
[4166] => bcdeg
[4167] => bcdeh
[4197] => bcdfg
[4199] => bcdfh
[4206] => bcdgh
[4356] => bcefg
[4359] => bcefh
[4374] => bcegh
[4421] => bcfgh
[4963] => bdefg
[4967] => bdefh
[4990] => bdegh
[5093] => bdfgh
[5364] => befgh
[6242] => cdefg
[6247] => cdefh
[6278] => cdegh
[6437] => cdfgh
[7044] => cefgh
[8323] => defgh
[8800] => abcdef
[8806] => abcdeg
[8807] => abcdeh
[8845] => abcdfg
[8847] => abcdfh
[8854] => abcdgh
[9060] => abcefg
[9063] => abcefh
[9078] => abcegh
[9125] => abcfgh
[10003] => abdefg
[10007] => abdefh
[10030] => abdegh
[10133] => abdfgh
[10404] => abefgh
[12962] => acdefg
[12967] => acdefh
[12998] => acdegh
[13157] => acdfgh
[13764] => acefgh
[15043] => adefgh
[17601] => bcdefg
[17607] => bcdefh
[17646] => bcdegh
[17861] => bcdfgh
[18804] => bcefgh
[21763] => bdefgh
[26402] => cdefgh
[28960] => abcdefg
[28967] => abcdefh
[29014] => abcdegh
[29285] => abcdfgh
[30564] => abcefgh
[35203] => abdefgh
[46562] => acdefgh
[57921] => bcdefgh
[69280] => abcdefgh
)
- Output for 5.1.0 - 5.1.6, 5.2.0 - 5.2.8
- Warning: Wrong parameter count for array_unique() in /in/RqRd3 on line 37
- Output for 5.0.4 - 5.0.5
Process exited with code 137.
preferences:
336.49 ms | 401 KiB | 434 Q