Permutations of a set of characters
I forget why I did this, but given a set of characters, how many combinations of all those characters are there? This is code to figure it out for 3 character positions.
Number of permutations: 1000 3^10
AAA AAB AAC AAD AAE AAF AAG AAH AAI AAJ ABA ABB ABC ABD ABE ABF ABG ABH ABI ABJ ACA ACB ACC ACD ACE ACF ACG ACH ACI ACJ ADA ADB ADC ADD ADE ADF ADG ADH ADI ADJ AEA AEB AEC AED AEE AEF AEG AEH AEI AEJ AFA AFB AFC AFD AFE AFF AFG AFH AFI AFJ AGA AGB AGC AGD AGE AGF AGG AGH AGI AGJ AHA AHB AHC AHD AHE AHF AHG AHH AHI AHJ AIA AIB AIC AID AIE AIF AIG AIH AII AIJ AJA AJB AJC AJD AJE AJF AJG AJH AJI AJJ BAA BAB BAC BAD BAE BAF BAG BAH BAI BAJ BBA BBB BBC BBD BBE BBF BBG BBH BBI BBJ BCA BCB BCC BCD BCE BCF BCG BCH BCI BCJ BDA BDB BDC BDD BDE BDF BDG BDH BDI BDJ BEA BEB BEC BED BEE BEF BEG BEH BEI BEJ BFA BFB BFC BFD BFE BFF BFG BFH BFI BFJ BGA BGB BGC BGD BGE BGF BGG BGH BGI BGJ BHA BHB BHC BHD BHE BHF BHG BHH BHI BHJ BIA BIB BIC BID BIE BIF BIG BIH BII BIJ BJA BJB BJC BJD BJE BJF BJG BJH BJI BJJ CAA CAB CAC CAD CAE CAF CAG CAH CAI CAJ CBA CBB CBC CBD CBE CBF CBG CBH CBI CBJ CCA CCB CCC CCD CCE CCF CCG CCH CCI CCJ CDA CDB CDC CDD CDE CDF CDG CDH CDI CDJ CEA CEB CEC CED CEE CEF CEG CEH CEI CEJ CFA CFB CFC CFD CFE CFF CFG CFH CFI CFJ CGA CGB CGC CGD CGE CGF CGG CGH CGI CGJ CHA CHB CHC CHD CHE CHF CHG CHH CHI CHJ CIA CIB CIC CID CIE CIF CIG CIH CII CIJ CJA CJB CJC CJD CJE CJF CJG CJH CJI CJJ DAA DAB DAC DAD DAE DAF DAG DAH DAI DAJ DBA DBB DBC DBD DBE DBF DBG DBH DBI DBJ DCA DCB DCC DCD DCE DCF DCG DCH DCI DCJ DDA DDB DDC DDD DDE DDF DDG DDH DDI DDJ DEA DEB DEC DED DEE DEF DEG DEH DEI DEJ DFA DFB DFC DFD DFE DFF DFG DFH DFI DFJ DGA DGB DGC DGD DGE DGF DGG DGH DGI DGJ DHA DHB DHC DHD DHE DHF DHG DHH DHI DHJ DIA DIB DIC DID DIE DIF DIG DIH DII DIJ DJA DJB DJC DJD DJE DJF DJG DJH DJI DJJ EAA EAB EAC EAD EAE EAF EAG EAH EAI EAJ EBA EBB EBC EBD EBE EBF EBG EBH EBI EBJ ECA ECB ECC ECD ECE ECF ECG ECH ECI ECJ EDA EDB EDC EDD EDE EDF EDG EDH EDI EDJ EEA EEB EEC EED EEE EEF EEG EEH EEI EEJ EFA EFB EFC EFD EFE EFF EFG EFH EFI EFJ EGA EGB EGC EGD EGE EGF EGG EGH EGI EGJ EHA EHB EHC EHD EHE EHF EHG EHH EHI EHJ EIA EIB EIC EID EIE EIF EIG EIH EII EIJ EJA EJB EJC EJD EJE EJF EJG EJH EJI EJJ FAA FAB FAC FAD FAE FAF FAG FAH FAI FAJ FBA FBB FBC FBD FBE FBF FBG FBH FBI FBJ FCA FCB FCC FCD FCE FCF FCG FCH FCI FCJ FDA FDB FDC FDD FDE FDF FDG FDH FDI FDJ FEA FEB FEC FED FEE FEF FEG FEH FEI FEJ FFA FFB FFC FFD FFE FFF FFG FFH FFI FFJ FGA FGB FGC FGD FGE FGF FGG FGH FGI FGJ FHA FHB FHC FHD FHE FHF FHG FHH FHI FHJ FIA FIB FIC FID FIE FIF FIG FIH FII FIJ FJA FJB FJC FJD FJE FJF FJG FJH FJI FJJ GAA GAB GAC GAD GAE GAF GAG GAH GAI GAJ GBA GBB GBC GBD GBE GBF GBG GBH GBI GBJ GCA GCB GCC GCD GCE GCF GCG GCH GCI GCJ GDA GDB GDC GDD GDE GDF GDG GDH GDI GDJ GEA GEB GEC GED GEE GEF GEG GEH GEI GEJ GFA GFB GFC GFD GFE GFF GFG GFH GFI GFJ GGA GGB GGC GGD GGE GGF GGG GGH GGI GGJ GHA GHB GHC GHD GHE GHF GHG GHH GHI GHJ GIA GIB GIC GID GIE GIF GIG GIH GII GIJ GJA GJB GJC GJD GJE GJF GJG GJH GJI GJJ HAA HAB HAC HAD HAE HAF HAG HAH HAI HAJ HBA HBB HBC HBD HBE HBF HBG HBH HBI HBJ HCA HCB HCC HCD HCE HCF HCG HCH HCI HCJ HDA HDB HDC HDD HDE HDF HDG HDH HDI HDJ HEA HEB HEC HED HEE HEF HEG HEH HEI HEJ HFA HFB HFC HFD HFE HFF HFG HFH HFI HFJ HGA HGB HGC HGD HGE HGF HGG HGH HGI HGJ HHA HHB HHC HHD HHE HHF HHG HHH HHI HHJ HIA HIB HIC HID HIE HIF HIG HIH HII HIJ HJA HJB HJC HJD HJE HJF HJG HJH HJI HJJ IAA IAB IAC IAD IAE IAF IAG IAH IAI IAJ IBA IBB IBC IBD IBE IBF IBG IBH IBI IBJ ICA ICB ICC ICD ICE ICF ICG ICH ICI ICJ IDA IDB IDC IDD IDE IDF IDG IDH IDI IDJ IEA IEB IEC IED IEE IEF IEG IEH IEI IEJ IFA IFB IFC IFD IFE IFF IFG IFH IFI IFJ IGA IGB IGC IGD IGE IGF IGG IGH IGI IGJ IHA IHB IHC IHD IHE IHF IHG IHH IHI IHJ IIA IIB IIC IID IIE IIF IIG IIH III IIJ IJA IJB IJC IJD IJE IJF IJG IJH IJI IJJ JAA JAB JAC JAD JAE JAF JAG JAH JAI JAJ JBA JBB JBC JBD JBE JBF JBG JBH JBI JBJ JCA JCB JCC JCD JCE JCF JCG JCH JCI JCJ JDA JDB JDC JDD JDE JDF JDG JDH JDI JDJ JEA JEB JEC JED JEE JEF JEG JEH JEI JEJ JFA JFB JFC JFD JFE JFF JFG JFH JFI JFJ JGA JGB JGC JGD JGE JGF JGG JGH JGI JGJ JHA JHB JHC JHD JHE JHF JHG JHH JHI JHJ JIA JIB JIC JID JIE JIF JIG JIH JII JIJ JJA JJB JJC JJD JJE JJF JJG JJH JJI JJJ
Source
<?php $legal_chars = "ABCDEFGH"; for($i=0;$i<strlen($legal_chars);$i++) $char_arr[] = $legal_chars{$i}; foreach ($char_arr as $x) foreach ($char_arr as $y) foreach ($char_arr as $z) $permutate_arr[] = $x . $y . $z; print "<p style=\"font-family: courier, 'courier new',fixed-width;\">"; print "Number of permutations: " . sizeof($permutate_arr) . " 3^" . strlen($legal_chars); print "</p>"; print "<p style=\"font-family: courier, 'courier new',fixed-width;\">"; foreach ($permutate_arr as $a) { print $a . " "; flush(); } print "</p>"; ?>