Just another update

This commit is contained in:
Ingy döt Net 2015-02-20 00:35:01 -05:00
parent a25938f123
commit 00a190b0a6
6591 changed files with 94363 additions and 23227 deletions

View file

@ -1,26 +1,30 @@
/*REXX program finds a missing permuation from an internal list. */
/*REXX program finds (a) missing permutation(s) 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'
@.= /* [↓] needs to be THINGS long. */
@abcU = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' /*an uppercase (Latin) alphabet. */
things = 4 /*# of unique letters to be used.*/
bunch = 4 /*# letters to be used at a time.*/
do j=1 for things
$.j=substr(@abcU,j,1)
end /*j*/ /* [↑] construct a letter array.*/
call permset 1 /*invoke PERMSET (recursively).*/
exit /*stick a fork in it, we're done.*/
/*──────────────────────────────────PERMSET subroutine──────────────────*/
permset: procedure expose $. @. bunch list things; parse arg ?
if ?>bunch then do
_=; do m=1 for bunch /*build permutation*/
_=_ || @.m /*add perm ──► list*/
end /*m*/
/* [↓] is in list?*/
if wordpos(_,list)==0 then say _ ' is missing from the list.'
end
else do x=1 for things /*build a new perm.*/
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
do j=1 for things /*build list of permutation obj. */
$.j=substr(@abcu,j,1)
end /*j*/
call permset 1
exit
/*─────────────────────────────────────PERMSET subroutine───────────────*/
permset:procedure expose $. @. bunch list things; parse arg ?
if ?>bunch then do; _=@.1; do m=2 to bunch
_=_||@.m
end /*m*/
if wordpos(_,list)==0 then say _ ' is missing from the list.'
end
else do x=1 for things /*construction a new permuation. */
do k=1 for ?-1; if @.k==$.x then iterate x; end /*k*/
@.?=$.x
call permset ?+1
end /*x*/
do k=1 for ?-1
if @.k==$.x then iterate x /*been built?*/
end /*k*/
@.?=$.x /*define as built. */
call permset ?+1 /*call recursively.*/
end /*x*/
return