Find the missing permutation: Difference between revisions

Content added Content deleted
(→‎{{header|Racket}}: Naive method (using new builtin), and better style)
(octave added)
Line 895: Line 895:
find_missing deficient_perms;;
find_missing deficient_perms;;
(* - : string = "DBAC" *)</lang>
(* - : 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}}==
=={{header|Oz}}==
Line 918: Line 934:
end
end
end</lang>
end</lang>

=={{header|PHP}}==
=={{header|PHP}}==
<lang php><?php
<lang php><?php