Another update from ingydotnet^djgoku

This commit is contained in:
Ingy döt Net 2015-11-18 06:14:39 +00:00
parent 91df62d461
commit 948b86eafa
7604 changed files with 108452 additions and 22726 deletions

View file

@ -1,30 +1,29 @@
/*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 ?
/*REXX program finds one or more missing permutations 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 as long as THINGS.*/
@abcU = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' /*an uppercase (Latin/Roman) alphabet. */
things = 4 /*number of unique letters to be used. */
bunch = 4 /*number letters to be used at a time. */
do j=1 for things /* [↓] only get a portion of alphabet.*/
$.j=substr(@abcU,j,1) /*extract just one letter from alphabet*/
end /*j*/ /* [↑] build a letter array for speed.*/
call permSet 1 /*invoke PERMSET sub. (recursively). */
exit /*stick a fork in it, we're all done. */
/*────────────────────────────────────────────────────────────────────────────*/
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.'
_=; do m=1 for bunch /*build a permutation. */
_=_ || @.m /*add permutation──►list*/
end /*m*/
/* [↓] is in the list? */
if wordpos(_,list)==0 then say _ ' is missing from the list.'
end
else do x=1 for things /*build a new perm.*/
do k=1 for ?-1
if @.k==$.x then iterate x /*been built?*/
end /*k*/
@.?=$.x /*define as built. */
call permset ?+1 /*call recursively.*/
else do x=1 for things /*build a permutation. */
do k=1 for ?-1
if @.k==$.x then iterate x /*was permutation built?*/
end /*k*/
@.?=$.x /*define as being built.*/
call permSet ?+1 /*call subr. recursively*/
end /*x*/
return