Permutations: Difference between revisions

Line 2,302:
 
=={{header|Run BASIC}}==
<lang Runbasic>list$ = "ah,be,cl,dl,eo" ' supply list seperated with comma's
 
while word$(list$,d+1,",") <> "" 'Count how many in the list
d = d + 1
wend
 
dim theList$(d) ' place list in array
for i = 1 to d
theList$(i) = word$(list$,i,",")
next i
 
for i = 1 to d ' print the Permutations
for j = d to 2 step -1
perm$ = ""
for k = 1 to d
printperm$ = perm$ + theList$(k);
next k
if instr(perms$,perm$+",") = 0 then print perm$
print
perms$ = perms$ + perm$ + ","
h$ = theList$(j)
theList$(j) = theList$(j - 1)
Line 2,325 ⟶ 2,327:
next i
end</lang>Output:
<pre>abcdehello
helol
abced
heoll
abecd
hoell
aebcd
ohell
eabcd
ohlel
eabdc
olhel
eadbc
lohel
edabc
lohle
deabc
lolhe
deacb
llohe
decab
lloeh
dceab
lleoh
cdeab
leloh
cdeba
elloh
cdbea
ellho
cbdea
elhlo
bcdea
bacdeehllo</pre>
bcdae
bcade
bacde</pre>
 
=={{header|SAS}}==
Anonymous user