Anonymous user
Find the missing permutation: Difference between revisions
→{{header|REXX}}: condensed the REXX program to not use a subroutine and other structural changes. -- ~~~~
(→{{header|REXX}}: condensed the REXX program to not use a subroutine and other structural changes. -- ~~~~) |
|||
Line 1,115:
=={{header|REXX}}==
<lang rexx>/*REXX program finds a missing permuation from an internal list. */▼
▲/*REXX program finds a missing permuation from an internal list. */
list='ABCD CABD ACDB DACB BCDA ACBD ADCB CDAB DABC BCAD CADB CDBA',
'CBAD ABDC ADBC BDCA DCBA BACD BADC BDAC CBDA DBCA DCAB'
@.=; @abcU='ABCDEFGUIJKLMNOPQRSTUVWXYZ'
things=4
bunch=4
$.j=substr(@abcu,j,1)▼
end /*j*/
▲ do j=1 for things /*build list of permutation obj. */
▲ $.j=substr(@abcu,j,1)
▲call permset(1)
exit
/*─────────────────────────────────────PERMSET subroutine───────────────*/
if ?>bunch then do; _=@.1; do m=2 to bunch
▲permset:procedure expose (!); parse arg ?
_=_||@.m
if wordpos(_,list)==0
else do x=1 for things
do k=1 for ?-1; if @.k==$.x then iterate x; end /*k*/
@.?=$.x
call permset
end /*x*/
return</lang>
'''output'''
<pre style="height:5ex;overflow:scroll">
DBAC is missing from the list.
</pre>
|