Jump to content

Find the missing permutation: Difference between revisions

Add APL
(Added Wren)
(Add APL)
Line 204:
{{Out}}
<pre>DBAC</pre>
 
=={{header|APL}}==
 
This is a function that takes a matrix where the rows are permutations,
and returns the missing permutation. It works by returning, for each column,
the letter that occurs least.
 
<lang APL>missing ← ((⊂↓⍳¨⌊/) +⌿∘(⊢∘.=∪∘∊)) ⌷ ∪∘∊</lang>
 
{{out}}
 
<lang APL> perms←↑'ABCD' 'CABD' 'ACDB' 'DACB' 'BCDA' 'ACBD' 'ADCB' 'CDAB'
perms⍪←↑'DABC' 'BCAD' 'CADB' 'CDBA' 'CBAD' 'ABDC' 'ADBC' 'BDCA'
perms⍪←↑'DCBA' 'BACD' 'BADC' 'BDAC' 'CBDA' 'DBCA' 'DCAB'
missing perms
DBAC</lang>
 
=={{header|AppleScript}}==
2,095

edits

Cookies help us deliver our services. By using our services, you agree to our use of cookies.