The Math Forum

Ask Dr. Math - Questions and Answers from our Archives
Associated Topics || Dr. Math Home || Search Dr. Math

Generating Permutations With a Computer

Date: 06/20/2002 at 08:49:29
From: Tom Guglielmo
Subject: distinguishable permutations

Dear Dr. Math,

I have a friend named REBECCA who is celebrating her 50th birthday, 
and I was trying to find a calculator on the web that would list all 
the distinguishable permutations of all the letters of her name, but 
I was unable to locate one.  Are you aware of any?

Thank you,

Tom Guglielmo.

Date: 06/24/2002 at 13:38:25
From: Doctor Ian
Subject: Re: distinguishable permutations

Hi Tom, 

I couldn't find any calculators like that.  The ones I could find 
would tell you HOW MANY permutations can be made, but not what 
they are. 

Here is a simple Perl script that will compute them:


  my @incomplete = ':rebecca';
  my %complete;

  while ( my $item = pop( @incomplete ) ) {
      process( $item );

  print join( ' ', sort keys %complete ), "\n";

  sub process {
      my $item = shift;
      $item =~ /(.*):(.*)/;
      if ( $2 ) {
          extend( $1, $2 );
      else {
          $complete{$1} = 1;

  sub extend {
      my ( $done, $todo ) = @_;

      my @chars = split( '', $todo );

      foreach my $c ( @chars ) {
          my $removed = $todo;
          $removed =~ s/$c//;
          push( @incomplete, "$done$c:$removed" ); 

In case you aren't set up to execute Perl scripts, here are the 
resulting permutations:

  abcceer abccere abccree abcecer abcecre abceecr abceerc abcerce
  abcerec abcrcee abcrece abcreec abeccer abeccre abececr abecerc
  abecrce abecrec abeeccr abeecrc abeercc abercce abercec aberecc
  abrccee abrcece abrceec abrecce abrecec abreecc acbceer acbcere
  acbcree acbecer acbecre acbeecr acbeerc acberce acberec acbrcee
  acbrece acbreec accbeer accbere accbree acceber accebre acceebr
  acceerb accerbe accereb accrbee accrebe accreeb acebcer acebcre
  acebecr aceberc acebrce acebrec acecber acecbre acecebr acecerb
  acecrbe acecreb aceebcr aceebrc aceecbr aceecrb aceerbc aceercb
  acerbce acerbec acercbe acerceb acerebc acerecb acrbcee acrbece
  acrbeec acrcbee acrcebe acrceeb acrebce acrebec acrecbe acreceb
  acreebc acreecb aebccer aebccre aebcecr aebcerc aebcrce aebcrec
  aebeccr aebecrc aebercc aebrcce aebrcec aebrecc aecbcer aecbcre
  aecbecr aecberc aecbrce aecbrec aeccber aeccbre aeccebr aeccerb
  aeccrbe aeccreb aecebcr aecebrc aececbr aececrb aecerbc aecercb
  aecrbce aecrbec aecrcbe aecrceb aecrebc aecrecb aeebccr aeebcrc
  aeebrcc aeecbcr aeecbrc aeeccbr aeeccrb aeecrbc aeecrcb aeerbcc
  aeercbc aeerccb aerbcce aerbcec aerbecc aercbce aercbec aerccbe
  aercceb aercebc aercecb aerebcc aerecbc aereccb arbccee arbcece
  arbceec arbecce arbecec arbeecc arcbcee arcbece arcbeec arccbee
  arccebe arcceeb arcebce arcebec arcecbe arceceb arceebc arceecb
  arebcce arebcec arebecc arecbce arecbec areccbe arecceb arecebc
  arececb areebcc areecbc areeccb bacceer baccere baccree bacecer
  bacecre baceecr baceerc bacerce bacerec bacrcee bacrece bacreec
  baeccer baeccre baececr baecerc baecrce baecrec baeeccr baeecrc
  baeercc baercce baercec baerecc barccee barcece barceec barecce
  barecec bareecc bcaceer bcacere bcacree bcaecer bcaecre bcaeecr
  bcaeerc bcaerce bcaerec bcarcee bcarece bcareec bccaeer bccaere
  bccaree bcceaer bcceare bcceear bcceera bccerae bccerea bccraee
  bccreae bccreea bceacer bceacre bceaecr bceaerc bcearce bcearec
  bcecaer bcecare bcecear bcecera bcecrae bcecrea bceeacr bceearc
  bceecar bceecra bceerac bceerca bcerace bceraec bcercae bcercea
  bcereac bcereca bcracee bcraece bcraeec bcrcaee bcrceae bcrceea
  bcreace bcreaec bcrecae bcrecea bcreeac bcreeca beaccer beaccre
  beacecr beacerc beacrce beacrec beaeccr beaecrc beaercc bearcce
  bearcec bearecc becacer becacre becaecr becaerc becarce becarec
  beccaer beccare beccear beccera beccrae beccrea beceacr becearc
  bececar bececra becerac becerca becrace becraec becrcae becrcea
  becreac becreca beeaccr beeacrc beearcc beecacr beecarc beeccar
  beeccra beecrac beecrca beeracc beercac beercca beracce beracec
  beraecc bercace bercaec berccae berccea berceac berceca bereacc
  berecac berecca braccee bracece braceec braecce braecec braeecc
  brcacee brcaece brcaeec brccaee brcceae brcceea brceace brceaec
  brcecae brcecea brceeac brceeca breacce breacec breaecc brecace
  brecaec breccae breccea breceac brececa breeacc breecac breecca
  cabceer cabcere cabcree cabecer cabecre cabeecr cabeerc caberce
  caberec cabrcee cabrece cabreec cacbeer cacbere cacbree caceber
  cacebre caceebr caceerb cacerbe cacereb cacrbee cacrebe cacreeb
  caebcer caebcre caebecr caeberc caebrce caebrec caecber caecbre
  caecebr caecerb caecrbe caecreb caeebcr caeebrc caeecbr caeecrb
  caeerbc caeercb caerbce caerbec caercbe caerceb caerebc caerecb
  carbcee carbece carbeec carcbee carcebe carceeb carebce carebec
  carecbe careceb careebc careecb cbaceer cbacere cbacree cbaecer
  cbaecre cbaeecr cbaeerc cbaerce cbaerec cbarcee cbarece cbareec
  cbcaeer cbcaere cbcaree cbceaer cbceare cbceear cbceera cbcerae
  cbcerea cbcraee cbcreae cbcreea cbeacer cbeacre cbeaecr cbeaerc
  cbearce cbearec cbecaer cbecare cbecear cbecera cbecrae cbecrea
  cbeeacr cbeearc cbeecar cbeecra cbeerac cbeerca cberace cberaec
  cbercae cbercea cbereac cbereca cbracee cbraece cbraeec cbrcaee
  cbrceae cbrceea cbreace cbreaec cbrecae cbrecea cbreeac cbreeca
  ccabeer ccabere ccabree ccaeber ccaebre ccaeebr ccaeerb ccaerbe
  ccaereb ccarbee ccarebe ccareeb ccbaeer ccbaere ccbaree ccbeaer
  ccbeare ccbeear ccbeera ccberae ccberea ccbraee ccbreae ccbreea
  cceaber cceabre cceaebr cceaerb ccearbe cceareb ccebaer ccebare
  ccebear ccebera ccebrae ccebrea cceeabr cceearb cceebar cceebra
  cceerab cceerba ccerabe cceraeb ccerbae ccerbea ccereab ccereba
  ccrabee ccraebe ccraeeb ccrbaee ccrbeae ccrbeea ccreabe ccreaeb
  ccrebae ccrebea ccreeab ccreeba ceabcer ceabcre ceabecr ceaberc
  ceabrce ceabrec ceacber ceacbre ceacebr ceacerb ceacrbe ceacreb
  ceaebcr ceaebrc ceaecbr ceaecrb ceaerbc ceaercb cearbce cearbec
  cearcbe cearceb cearebc cearecb cebacer cebacre cebaecr cebaerc
  cebarce cebarec cebcaer cebcare cebcear cebcera cebcrae cebcrea
  cebeacr cebearc cebecar cebecra ceberac ceberca cebrace cebraec
  cebrcae cebrcea cebreac cebreca cecaber cecabre cecaebr cecaerb
  cecarbe cecareb cecbaer cecbare cecbear cecbera cecbrae cecbrea
  ceceabr cecearb cecebar cecebra cecerab cecerba cecrabe cecraeb
  cecrbae cecrbea cecreab cecreba ceeabcr ceeabrc ceeacbr ceeacrb
  ceearbc ceearcb ceebacr ceebarc ceebcar ceebcra ceebrac ceebrca
  ceecabr ceecarb ceecbar ceecbra ceecrab ceecrba ceerabc ceeracb
  ceerbac ceerbca ceercab ceercba cerabce cerabec ceracbe ceraceb
  ceraebc ceraecb cerbace cerbaec cerbcae cerbcea cerbeac cerbeca
  cercabe cercaeb cercbae cercbea cerceab cerceba cereabc cereacb
  cerebac cerebca cerecab cerecba crabcee crabece crabeec cracbee
  cracebe craceeb craebce craebec craecbe craeceb craeebc craeecb
  crbacee crbaece crbaeec crbcaee crbceae crbceea crbeace crbeaec
  crbecae crbecea crbeeac crbeeca crcabee crcaebe crcaeeb crcbaee
  crcbeae crcbeea crceabe crceaeb crcebae crcebea crceeab crceeba
  creabce creabec creacbe creaceb creaebc creaecb crebace crebaec
  crebcae crebcea crebeac crebeca crecabe crecaeb crecbae crecbea
  creceab creceba creeabc creeacb creebac creebca creecab creecba
  eabccer eabccre eabcecr eabcerc eabcrce eabcrec eabeccr eabecrc
  eabercc eabrcce eabrcec eabrecc eacbcer eacbcre eacbecr eacberc
  eacbrce eacbrec eaccber eaccbre eaccebr eaccerb eaccrbe eaccreb
  eacebcr eacebrc eacecbr eacecrb eacerbc eacercb eacrbce eacrbec
  eacrcbe eacrceb eacrebc eacrecb eaebccr eaebcrc eaebrcc eaecbcr
  eaecbrc eaeccbr eaeccrb eaecrbc eaecrcb eaerbcc eaercbc eaerccb
  earbcce earbcec earbecc earcbce earcbec earccbe earcceb earcebc
  earcecb earebcc earecbc eareccb ebaccer ebaccre ebacecr ebacerc
  ebacrce ebacrec ebaeccr ebaecrc ebaercc ebarcce ebarcec ebarecc
  ebcacer ebcacre ebcaecr ebcaerc ebcarce ebcarec ebccaer ebccare
  ebccear ebccera ebccrae ebccrea ebceacr ebcearc ebcecar ebcecra
  ebcerac ebcerca ebcrace ebcraec ebcrcae ebcrcea ebcreac ebcreca
  ebeaccr ebeacrc ebearcc ebecacr ebecarc ebeccar ebeccra ebecrac
  ebecrca eberacc ebercac ebercca ebracce ebracec ebraecc ebrcace
  ebrcaec ebrccae ebrccea ebrceac ebrceca ebreacc ebrecac ebrecca
  ecabcer ecabcre ecabecr ecaberc ecabrce ecabrec ecacber ecacbre
  ecacebr ecacerb ecacrbe ecacreb ecaebcr ecaebrc ecaecbr ecaecrb
  ecaerbc ecaercb ecarbce ecarbec ecarcbe ecarceb ecarebc ecarecb
  ecbacer ecbacre ecbaecr ecbaerc ecbarce ecbarec ecbcaer ecbcare
  ecbcear ecbcera ecbcrae ecbcrea ecbeacr ecbearc ecbecar ecbecra
  ecberac ecberca ecbrace ecbraec ecbrcae ecbrcea ecbreac ecbreca
  eccaber eccabre eccaebr eccaerb eccarbe eccareb eccbaer eccbare
  eccbear eccbera eccbrae eccbrea ecceabr eccearb eccebar eccebra
  eccerab eccerba eccrabe eccraeb eccrbae eccrbea eccreab eccreba
  eceabcr eceabrc eceacbr eceacrb ecearbc ecearcb ecebacr ecebarc
  ecebcar ecebcra ecebrac ecebrca ececabr ececarb ececbar ececbra
  ececrab ececrba ecerabc eceracb ecerbac ecerbca ecercab ecercba
  ecrabce ecrabec ecracbe ecraceb ecraebc ecraecb ecrbace ecrbaec
  ecrbcae ecrbcea ecrbeac ecrbeca ecrcabe ecrcaeb ecrcbae ecrcbea
  ecrceab ecrceba ecreabc ecreacb ecrebac ecrebca ecrecab ecrecba
  eeabccr eeabcrc eeabrcc eeacbcr eeacbrc eeaccbr eeaccrb eeacrbc
  eeacrcb eearbcc eearcbc eearccb eebaccr eebacrc eebarcc eebcacr
  eebcarc eebccar eebccra eebcrac eebcrca eebracc eebrcac eebrcca
  eecabcr eecabrc eecacbr eecacrb eecarbc eecarcb eecbacr eecbarc
  eecbcar eecbcra eecbrac eecbrca eeccabr eeccarb eeccbar eeccbra
  eeccrab eeccrba eecrabc eecracb eecrbac eecrbca eecrcab eecrcba
  eerabcc eeracbc eeraccb eerbacc eerbcac eerbcca eercabc eercacb
  eercbac eercbca eerccab eerccba erabcce erabcec erabecc eracbce
  eracbec eraccbe eracceb eracebc eracecb eraebcc eraecbc eraeccb
  erbacce erbacec erbaecc erbcace erbcaec erbccae erbccea erbceac
  erbceca erbeacc erbecac erbecca ercabce ercabec ercacbe ercaceb
  ercaebc ercaecb ercbace ercbaec ercbcae ercbcea ercbeac ercbeca
  erccabe erccaeb erccbae erccbea ercceab ercceba erceabc erceacb
  ercebac ercebca ercecab ercecba ereabcc ereacbc ereaccb erebacc
  erebcac erebcca erecabc erecacb erecbac erecbca ereccab ereccba
  rabccee rabcece rabceec rabecce rabecec rabeecc racbcee racbece
  racbeec raccbee raccebe racceeb racebce racebec racecbe raceceb
  raceebc raceecb raebcce raebcec raebecc raecbce raecbec raeccbe
  raecceb raecebc raececb raeebcc raeecbc raeeccb rbaccee rbacece
  rbaceec rbaecce rbaecec rbaeecc rbcacee rbcaece rbcaeec rbccaee
  rbcceae rbcceea rbceace rbceaec rbcecae rbcecea rbceeac rbceeca
  rbeacce rbeacec rbeaecc rbecace rbecaec rbeccae rbeccea rbeceac
  rbececa rbeeacc rbeecac rbeecca rcabcee rcabece rcabeec rcacbee
  rcacebe rcaceeb rcaebce rcaebec rcaecbe rcaeceb rcaeebc rcaeecb
  rcbacee rcbaece rcbaeec rcbcaee rcbceae rcbceea rcbeace rcbeaec
  rcbecae rcbecea rcbeeac rcbeeca rccabee rccaebe rccaeeb rccbaee
  rccbeae rccbeea rcceabe rcceaeb rccebae rccebea rcceeab rcceeba
  rceabce rceabec rceacbe rceaceb rceaebc rceaecb rcebace rcebaec
  rcebcae rcebcea rcebeac rcebeca rcecabe rcecaeb rcecbae rcecbea
  rceceab rceceba rceeabc rceeacb rceebac rceebca rceecab rceecba
  reabcce reabcec reabecc reacbce reacbec reaccbe reacceb reacebc
  reacecb reaebcc reaecbc reaeccb rebacce rebacec rebaecc rebcace
  rebcaec rebccae rebccea rebceac rebceca rebeacc rebecac rebecca
  recabce recabec recacbe recaceb recaebc recaecb recbace recbaec
  recbcae recbcea recbeac recbeca reccabe reccaeb reccbae reccbea
  recceab recceba receabc receacb recebac recebca rececab rececba
  reeabcc reeacbc reeaccb reebacc reebcac reebcca reecabc reecacb
  reecbac reecbca reeccab reeccba

Too small for a poster, too big to engrave on a bracelet.  :^D

I hope this helps.  Write back if you'd like to talk more about 
this, or anything else.

- Doctor Ian, The Math Forum 
Associated Topics:
High School Calculators, Computers
High School Permutations and Combinations

Search the Dr. Math Library:

Find items containing (put spaces between keywords):
Click only once for faster results:

[ Choose "whole words" when searching for a word like age.]

all keywords, in any order at least one, that exact phrase
parts of words whole words

Submit your own question to Dr. Math

[Privacy Policy] [Terms of Use]

Math Forum Home || Math Library || Quick Reference || Math Forum Search

Ask Dr. MathTM
© 1994- The Math Forum at NCTM. All rights reserved.