Tutorial illustrating the use of TMath::Permute can be run with:
TMath::Permute simple test
==========================
abcd
abdc
acbd
acdb
adbc
adcb
bacd
badc
bcad
bcda
bdac
bdca
cabd
cadb
cbad
cbda
cdab
cdba
dabc
dacb
dbac
dbca
dcab
dcba
Found 24 permutations = 4!
TMath::Permute simple test with repetition
==========================================
aabbc
aabcb
aacbb
ababc
abacb
abbac
abbca
abcab
abcba
acabb
acbab
acbba
baabc
baacb
babac
babca
bacab
bacba
bbaac
bbaca
bbcaa
bcaab
bcaba
bcbaa
caabb
cabab
cabba
cbaab
cbaba
cbbaa
Found 30 permutations = 5!/(2! 2!)
TMath::Permute fancy test
=========================
This is a program to calculate the solution to the following problem
Find the equivalence between letters and numbers so that
NINE*THREE = NEUF*TROIS
Solution found!
T=1 N=9 E=6 S=7 F=8 H=3 R=2 I=0 O=5 U=4
NINE=9096 THREE=13266 NEUF=9648 TROIS=12507
NINE*THREE = NEUF*TROIS = 120667536
{
printf(
"\nTMath::Permute simple test\n");
printf(
"==========================\n");
for(i=0; i<4; i++)
a[i]=i;
do {
return 0;
}
{
printf(
"\nTMath::Permute simple test with repetition\n");
printf(
"==========================================\n");
for(i=0; i<6; i++)
a[i]=(i+2)/2;
do {
return 0;
}
{
printf(
"\nTMath::Permute fancy test\n");
printf(
"=========================\n");
printf(
"This is a program to calculate the solution to the following problem\n");
printf(
"Find the equivalence between letters and numbers so that\n\n");
printf(
" NINE*THREE = NEUF*TROIS\n\n");
do {
trois=(((t*10+
r)*10+o)*10+i)*10+s;
printf(
"Solution found!\n\n");
printf(
"T=%d N=%d E=%d S=%d F=%d H=%d R=%d I=%d O=%d U=%d\n",t,
n,
e,s,
f,
h,
r,i,o,
u);
return 0;
}
printf(
"No solutions found -- something is wrong here!\n");
return 0;
}
}
ROOT::Detail::TRangeCast< T, true > TRangeDynCast
TRangeDynCast is an adapter class that allows the typed iteration through a TCollection.
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t WindowAttributes_t Float_t r
Bool_t Permute(Int_t n, Int_t *a)
Simple recursive algorithm to find the permutations of n natural numbers, not necessarily all distinc...
- Author
- Federico Carminati
Definition in file permute.C.