Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Here it is done with Recursion (Credit to this post's accepted answer:<a href="https://stackoverflow.com/questions/17934622/how-to-generate-permutations-with-repeated-characters?lq=1">How to Generate Permutations With Repeated Characters</a></p> <pre><code>program Combinations; {$APPTYPE CONSOLE} {$R *.res} uses System.SysUtils; procedure displayPermutation(const permutation : array of char; ilength: integer); var i: integer; begin for i := 0 to ilength - 1 do begin if i mod iLength = 0 then writeln('') else write(permutation[i]); end; end; procedure getPermutations(const operatorBank: array of char; operatorCount: integer; permutation: array of char; permutationLength, curIndex: integer); var i : integer; begin //stop recursion condition if(curIndex = permutationLength)then displayPermutation(permutation, permutationLength) else for i := 0 to operatorCount - 1 do begin permutation[curIndex] := operatorBank[i]; getPermutations(operatorBank,operatorCount,permutation, permutationLength,curIndex+1); end; end; var operatorBank,permutation : array of char; i, permutationLength, curIndex, operatorCount: integer; Q, S : String; begin try Q := ' '; S := ' '; while (Q &lt;&gt; '') and (S &lt;&gt; '') do begin Writeln(''); Write('P(N,R) N=? : '); ReadLn(Q); operatorCount := Length(Q); setLength(operatorBank,operatorCount); for i := 0 to operatorCount - 1 do operatorBank[i] := Q[i+1]; Write('P(N,R) R=? : '); ReadLn(S); if S &lt;&gt; '' then permutationLength := StrToInt(S) + 1; SetLength(permutation,operatorCount); curIndex := 0; Writeln(''); getPermutations(operatorBank, operatorCount, permutation, permutationLength, curIndex ); end; except on E: Exception do Writeln(E.ClassName, ': ', E.Message); end; end. </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload