Find the missing permutation: Difference between revisions
Content deleted Content added
PatGarrett (talk | contribs) →{{header|360 Assembly}}: Section added |
|||
Line 41: | Line 41: | ||
DBCA |
DBCA |
||
DCAB</pre> |
DCAB</pre> |
||
=={{header|360 Assembly}}== |
|||
{{trans|BBC BASIC}} |
|||
Very compact version, thanks to the clever Perl6 "xor" algorithm. |
|||
<lang 360asm> |
|||
* Find the missing permutation - 19/10/2015 |
|||
PERMMISX CSECT |
|||
USING PERMMISX,R15 set base register |
|||
LA R4,0 i=0 |
|||
LA R6,1 step |
|||
LA R7,23 to |
|||
LOOPI BXH R4,R6,ELOOPI do i=1 to hbound(perms) |
|||
LA R5,0 j=0 |
|||
LA R8,1 step |
|||
LA R9,4 to |
|||
LOOPJ BXH R5,R8,ELOOPJ do j=1 to hbound(miss) |
|||
LR R1,R4 i |
|||
SLA R1,2 *4 |
|||
LA R3,PERMS-5(R1) @perms(i) |
|||
AR R3,R5 j |
|||
LA R2,MISS-1(R5) @miss(j) |
|||
XC 0(1,R2),0(R3) miss(j)=miss(j) xor substr(perms(i),j,1) |
|||
B LOOPJ |
|||
ELOOPJ B LOOPI |
|||
ELOOPI XPRNT MISS,15 print buffer |
|||
XR R15,R15 set return code |
|||
BR R14 return to caller |
|||
PERMS DC C'ABCD',C'CABD',C'ACDB',C'DACB',C'BCDA',C'ACBD' |
|||
DC C'ADCB',C'CDAB',C'DABC',C'BCAD',C'CADB',C'CDBA' |
|||
DC C'CBAD',C'ABDC',C'ADBC',C'BDCA',C'DCBA',C'BACD' |
|||
DC C'BADC',C'BDAC',C'CBDA',C'DBCA',C'DCAB' |
|||
MISS DC 4XL1'00',C' is missing' buffer |
|||
YREGS |
|||
</lang> |
|||
{{out}} |
|||
<pre> |
|||
DBAC is missing |
|||
</pre> |
|||
=={{header|Ada}}== |
=={{header|Ada}}== |