Find the missing permutation: Difference between revisions

Content added Content deleted
m (→‎{{header|C}}: linkified permutation sort)
(J: the data is not a part of the implementation)
Line 230: Line 230:


=={{header|J}}==
=={{header|J}}==
<lang J>deficientPermsList=: }: ] ;. _1 LF, 0 : 0
<lang J>permutations=: A.~ i.@!@#
missingPerms =:-.~ permutations @ {.</lang>
Or putting things together:
<lang j>missingPerms =: -.~ (A.~ i.@!@#) @ {.</lang>
Use:
<pre>deficientPermsList=: }: ] ;. _1 LF, 0 : 0
ABCD
ABCD
CABD
CABD
Line 255: Line 260:
DCAB
DCAB
)
)
missingPerms deficientPermsList

permutations=: A.~ i.@!@#
missingPerms =:-.~ permutations @ {.</lang>
Or putting things together:
<lang j>missingPerms =: -.~ (A.~ i.@!@#) @ {.</lang>
Use:
<pre> missingPerms deficientPermsList
DBAC</pre>
DBAC</pre>