Permutations with repetitions: Difference between revisions

added Arturo
m (syntax highlighting fixup automation)
(added Arturo)
Line 401:
<pre>Permutation 589 of 1024: CRACK
Found after searching from AAAAA thru ARACK</pre>
 
=={{header|Arturo}}==
<syntaxhighlight lang="arturo">decide: function [pc]->
and? pc\0 = `B`
pc\1 = `C`
 
permutation: function [vals, n][
k: size vals
pn: array.of:n 0
p: array.of:n `0`
 
while [true][
loop.with:'i pn 'x -> p\[i]: vals\[x]
print p
if decide p -> return ø
i: 0
while [true][
pn\[i]: pn\[i] + 1
if pn\[i] < k -> break
pn\[i]: 0
i: i + 1
if i = n -> return ø
]
]
]
 
permutation "ABCD" 3</syntaxhighlight>
 
{{out}}
 
<pre>A A A
B A A
C A A
D A A
A B A
B B A
C B A
D B A
A C A
B C A</pre>
 
=={{header|AutoHotkey}}==
Line 437 ⟶ 477:
Return s
}</syntaxhighlight>
 
=={{header|AWK}}==
<syntaxhighlight lang="awk">
1,532

edits