Jump to content

Find the missing permutation: Difference between revisions

octave added
(→‎{{header|Racket}}: Naive method (using new builtin), and better style)
(octave added)
Line 895:
find_missing deficient_perms;;
(* - : string = "DBAC" *)</lang>
 
=={{header|Octave}}==
<lang octave>given = [ 'ABCD';'CABD';'ACDB';'DACB'; ...
'BCDA';'ACBD';'ADCB';'CDAB'; ...
'DABC';'BCAD';'CADB';'CDBA'; ...
'CBAD';'ABDC';'ADBC';'BDCA'; ...
'DCBA';'BACD';'BADC';'BDAC'; ...
'CBDA';'DBCA';'DCAB' ];
 
there = 1+(toascii(given)-toascii('A'))*4.^(0:3)';
every = 1+perms(0:3)*4.^(0:3)';
 
bits = zeros(max(every),1);
bits(every) = 1;
bits(there) = 0;
missing = dec2base(find(bits)-1,'ABCD')</lang>
 
=={{header|Oz}}==
Line 918 ⟶ 934:
end
end</lang>
 
=={{header|PHP}}==
<lang php><?php
Anonymous user
Cookies help us deliver our services. By using our services, you agree to our use of cookies.