In [6]:
from rcviz import CallGraph, viz
In [8]:
cg = CallGraph()
In [10]:
@viz(cg)
def permutations(s, prefix=""):
    n = len(s)
    if n == 0:
        print(prefix)
    else:
        for i in range(n):
            permutations(s[0:i] + s[i+1:n], prefix + s[i])
In [11]:
permutations("ape")
ape
aep
pae
pea
eap
epa
In [12]:
cg
callviz: Rendering in inline in Jupyter Notebook
Out[12]:
nodes=16 140705172602768 permutations(ape) ret: None 140705158098352 permutations(pe,a) ret: None 140705172602768->140705158098352 1 (⇑5) 140705171679120 permutations(ae,p) ret: None 140705172602768->140705171679120 6 (⇑10) 140705172597744 permutations(ap,e) ret: None 140705172602768->140705172597744 11 (⇑15) 140705172588608 permutations(e,ap) ret: None 140705158098352->140705172588608 2 (⇑2) 140705172600640 permutations(p,ae) ret: None 140705158098352->140705172600640 4 (⇑4) 140705157050384 permutations(,ape) ret: None 140705172588608->140705157050384 3 (⇑1) 140705171670144 permutations(,aep) ret: None 140705172600640->140705171670144 5 (⇑3) 140705172590976 permutations(e,pa) ret: None 140705171679120->140705172590976 7 (⇑7) 140705171696112 permutations(a,pe) ret: None 140705171679120->140705171696112 9 (⇑9) 140705172504944 permutations(,pae) ret: None 140705172590976->140705172504944 8 (⇑6) 140705172603296 permutations(,pea) ret: None 140705171696112->140705172603296 10 (⇑8) 140705171677872 permutations(p,ea) ret: None 140705172597744->140705171677872 12 (⇑12) 140705172586416 permutations(a,ep) ret: None 140705172597744->140705172586416 14 (⇑14) 140705171531792 permutations(,eap) ret: None 140705171677872->140705171531792 13 (⇑11) 140705172603824 permutations(,epa) ret: None 140705172586416->140705172603824 15 (⇑13)
In [13]:
permutations("apes")
apes
apse
aeps
aesp
aspe
asep
paes
pase
peas
pesa
psae
psea
eaps
easp
epas
epsa
esap
espa
sape
saep
spae
spea
seap
sepa
In [14]:
cg
callviz: Rendering in inline in Jupyter Notebook
Out[14]:
nodes=65 140705171698848 permutations(apes) ret: None 140705157051488 permutations(pes,a) ret: None 140705171698848->140705157051488 1 (⇑16) 140705172610192 permutations(aes,p) ret: None 140705171698848->140705172610192 17 (⇑32) 140705158104176 permutations(aps,e) ret: None 140705171698848->140705158104176 33 (⇑48) 140705157054752 permutations(ape,s) ret: None 140705171698848->140705157054752 49 (⇑64) 140705171699376 permutations(es,ap) ret: None 140705157051488->140705171699376 2 (⇑5) 140705172608176 permutations(ps,ae) ret: None 140705157051488->140705172608176 7 (⇑10) 140705172601696 permutations(pe,as) ret: None 140705157051488->140705172601696 12 (⇑15) 140705172606064 permutations(s,ape) ret: None 140705171699376->140705172606064 3 (⇑2) 140705172607120 permutations(e,aps) ret: None 140705171699376->140705172607120 5 (⇑4) 140705172606592 permutations(,apes) ret: None 140705172606064->140705172606592 4 (⇑1) 140705172607648 permutations(,apse) ret: None 140705172607120->140705172607648 6 (⇑3) 140705171700000 permutations(s,aep) ret: None 140705172608176->140705171700000 8 (⇑7) 140705158101632 permutations(p,aes) ret: None 140705172608176->140705158101632 10 (⇑9) 140705172608704 permutations(,aeps) ret: None 140705171700000->140705172608704 9 (⇑6) 140705172604352 permutations(,aesp) ret: None 140705158101632->140705172604352 11 (⇑8) 140705158097296 permutations(e,asp) ret: None 140705172601696->140705158097296 13 (⇑12) 140705158103120 permutations(p,ase) ret: None 140705172601696->140705158103120 15 (⇑14) 140705172599568 permutations(,aspe) ret: None 140705158097296->140705172599568 14 (⇑11) 140705158094480 permutations(,asep) ret: None 140705158103120->140705158094480 16 (⇑13) 140705172610720 permutations(es,pa) ret: None 140705172610192->140705172610720 18 (⇑21) 140705171701264 permutations(as,pe) ret: None 140705172610192->140705171701264 23 (⇑26) 140705172613888 permutations(ae,ps) ret: None 140705172610192->140705172613888 28 (⇑31) 140705158103648 permutations(s,pae) ret: None 140705172610720->140705158103648 19 (⇑18) 140705172611776 permutations(e,pas) ret: None 140705172610720->140705172611776 21 (⇑20) 140705172611248 permutations(,paes) ret: None 140705158103648->140705172611248 20 (⇑17) 140705172612304 permutations(,pase) ret: None 140705172611776->140705172612304 22 (⇑19) 140705171701792 permutations(s,pea) ret: None 140705171701264->140705171701792 24 (⇑23) 140705172612832 permutations(a,pes) ret: None 140705171701264->140705172612832 26 (⇑25) 140705171702320 permutations(,peas) ret: None 140705171701792->140705171702320 25 (⇑22) 140705172613360 permutations(,pesa) ret: None 140705172612832->140705172613360 27 (⇑24) 140705172614416 permutations(e,psa) ret: None 140705172613888->140705172614416 29 (⇑28) 140705158102160 permutations(a,pse) ret: None 140705172613888->140705158102160 31 (⇑30) 140705171702848 permutations(,psae) ret: None 140705172614416->140705171702848 30 (⇑27) 140705171703376 permutations(,psea) ret: None 140705158102160->140705171703376 32 (⇑29) 140705172614944 permutations(ps,ea) ret: None 140705158104176->140705172614944 34 (⇑37) 140705172616000 permutations(as,ep) ret: None 140705158104176->140705172616000 39 (⇑42) 140705172617584 permutations(ap,es) ret: None 140705158104176->140705172617584 44 (⇑47) 140705171703904 permutations(s,eap) ret: None 140705172614944->140705171703904 35 (⇑34) 140705172615472 permutations(p,eas) ret: None 140705172614944->140705172615472 37 (⇑36) 140705158104704 permutations(,eaps) ret: None 140705171703904->140705158104704 36 (⇑33) 140705171704432 permutations(,easp) ret: None 140705172615472->140705171704432 38 (⇑35) 140705172616528 permutations(s,epa) ret: None 140705172616000->140705172616528 40 (⇑39) 140705171704960 permutations(a,eps) ret: None 140705172616000->140705171704960 42 (⇑41) 140705172617056 permutations(,epas) ret: None 140705172616528->140705172617056 41 (⇑38) 140705171705488 permutations(,epsa) ret: None 140705171704960->140705171705488 43 (⇑40) 140705158105232 permutations(p,esa) ret: None 140705172617584->140705158105232 45 (⇑44) 140705172618640 permutations(a,esp) ret: None 140705172617584->140705172618640 47 (⇑46) 140705172618112 permutations(,esap) ret: None 140705158105232->140705172618112 46 (⇑43) 140705172619168 permutations(,espa) ret: None 140705172618640->140705172619168 48 (⇑45) 140705158105760 permutations(pe,sa) ret: None 140705157054752->140705158105760 50 (⇑53) 140705158106288 permutations(ae,sp) ret: None 140705157054752->140705158106288 55 (⇑58) 140705171707600 permutations(ap,se) ret: None 140705157054752->140705171707600 60 (⇑63) 140705171706016 permutations(e,sap) ret: None 140705158105760->140705171706016 51 (⇑50) 140705157055280 permutations(p,sae) ret: None 140705158105760->140705157055280 53 (⇑52) 140705172619696 permutations(,sape) ret: None 140705171706016->140705172619696 52 (⇑49) 140705171706544 permutations(,saep) ret: None 140705157055280->140705171706544 54 (⇑51) 140705172620224 permutations(e,spa) ret: None 140705158106288->140705172620224 56 (⇑55) 140705172620752 permutations(a,spe) ret: None 140705158106288->140705172620752 58 (⇑57) 140705171707072 permutations(,spae) ret: None 140705172620224->140705171707072 57 (⇑54) 140705172621856 permutations(,spea) ret: None 140705172620752->140705172621856 59 (⇑56) 140705172622384 permutations(p,sea) ret: None 140705171707600->140705172622384 61 (⇑60) 140705172622912 permutations(a,sep) ret: None 140705171707600->140705172622912 63 (⇑62) 140705157055808 permutations(,seap) ret: None 140705172622384->140705157055808 62 (⇑59) 140705172623440 permutations(,sepa) ret: None 140705172622912->140705172623440 64 (⇑61)