Find the missing permutation: Difference between revisions

J: the data is not a part of the implementation
m (→‎{{header|C}}: linkified permutation sort)
(J: the data is not a part of the implementation)
Line 230:
 
=={{header|J}}==
<lang J>deficientPermsListpermutations=: }:A.~ ] ;i. _1 LF, 0 : 0@!@#
missingPerms =:-.~ permutations @ {.</lang>
Or putting things together:
<lang j>missingPerms =: -.~ (A.~ i.@!@#) @ {.</lang>
Use:
<pre>deficientPermsList=: }: ] ;. _1 LF, 0 : 0
ABCD
CABD
Line 255 ⟶ 260:
DCAB
)
<pre> missingPerms deficientPermsList
 
permutations=: A.~ i.@!@#
missingPerms =:-.~ permutations @ {.</lang>
Or putting things together:
<lang j>missingPerms =: -.~ (A.~ i.@!@#) @ {.</lang>
Use:
<pre> missingPerms deficientPermsList
DBAC</pre>
 
6,962

edits