2016 Update
This commit is contained in:
parent
948b86eafa
commit
dcf5d15da3
7965 changed files with 139854 additions and 31002 deletions
|
|
@ -1,30 +1,30 @@
|
|||
/*REXX program finds words with the largest set of anagrams (of the same size)*/
|
||||
iFID='unixdict.txt' /*the dictionary input File IDentifier.*/
|
||||
$=; !.=; #.=0; w=0; uw=0; most=0 /*initialize a bunch of REXX variables.*/
|
||||
/* [↓] read the entire file (by lines)*/
|
||||
do while lines(iFID)\==0 /*Got any data? Then read a record. */
|
||||
@=space(linein(iFID),0) /*pick off a word from the input line. */
|
||||
L=length(@); if L<3 then iterate /*onesies and twosies words can't win. */
|
||||
if \datatype(@,'M') then iterate /*ignore any non─anagramable words. */
|
||||
uw=uw+1 /*count of the (useable) words in file.*/
|
||||
z=sortA(@) /*sort the letters in the word. */
|
||||
!.z=!.z @; #.z=#.z+1 /*append it to !.z; bump the counter. */
|
||||
/*REXX program finds words with the largest set of anagrams (of the same size). */
|
||||
iFID= 'unixdict.txt' /*the dictionary input File IDentifier.*/
|
||||
$=; !.=; #.=0; w=0; uw=0; most=0 /*initialize a bunch of REXX variables.*/
|
||||
/* [↓] read the entire file (by lines)*/
|
||||
do while lines(iFID)\==0 /*Got any data? Then read a record. */
|
||||
@=space( linein(iFID), 0) /*pick off a word from the input line. */
|
||||
L=length(@); if L<3 then iterate /*onesies and twosies words can't win. */
|
||||
if \datatype(@, 'M') then iterate /*ignore any non─anagramable words. */
|
||||
uw=uw+1 /*count of the (useable) words in file.*/
|
||||
z=sortA(@) /*sort the letters in the word. */
|
||||
!.z=!.z @; #.z=#.z+1 /*append it to !.z; bump the counter. */
|
||||
if #.z>most then do; $=z; most=#.z; if L>w then w=L; iterate; end
|
||||
if #.z==most then $=$ z /*append the sorted word──◄ max anagram*/
|
||||
end /*while*/ /*$ ►── list of high count anagrams. */
|
||||
say '─────────────────────────' uw 'useable words in the dictionary file: ' iFID
|
||||
if #.z==most then $=$ z /*append the sorted word──► max anagram*/
|
||||
end /*while*/ /*$ ◄── list of high count anagrams. */
|
||||
say '─────────────────────────' uw "useable words in the dictionary file: " iFID
|
||||
say
|
||||
do m=1 for words($); z=subword($,m,1) /*high count of anagrams.*/
|
||||
say ' ' left(subword(!.z,1,1),w) ' [anagrams: ' subword(!.z,2)"]"
|
||||
end /*m*/ /*W is the maximum width of any word.*/
|
||||
do m=1 for words($); z=subword($, m, 1) /*the high count of the anagrams. */
|
||||
say ' ' left(subword(!.z, 1, 1), w) ' [anagrams: ' subword(!.z, 2)"]"
|
||||
end /*m*/ /*W is the maximum width of any word.*/
|
||||
say
|
||||
say '───── Found' words($) "words (each of which have" #.z-1 'anagrams).'
|
||||
exit /*stick a fork in it, we're all done. */
|
||||
/*──────────────────────────────────SORTA subroutine──────────────────────────*/
|
||||
sortA: procedure; arg char +1 xx,@. /*get the first letter of arg; @.=null*/
|
||||
@.char=char /*no need to concatenate the first char*/
|
||||
/*[↓] sort/put letters alphabetically.*/
|
||||
do length(xx); parse var xx char +1 xx; @.char=@.char || char; end
|
||||
/*reassemble word with sorted letters. */
|
||||
return @.a||@.b||@.c||@.d||@.e||@.f||@.g||@.h||@.i||@.j||@.k||@.l||@.m||,
|
||||
@.n||@.o||@.p||@.q||@.r||@.s||@.t||@.u||@.v||@.w||@.x||@.y||@.z
|
||||
say '───── Found' words($) "words (each of which have" #.z-1 'anagrams).'
|
||||
exit /*stick a fork in it, we're all done. */
|
||||
/*──────────────────────────────────────────────────────────────────────────────────────*/
|
||||
sortA: procedure; arg char +1 xx,@. /*get the first letter of arg; @.=null*/
|
||||
@.char=char /*no need to concatenate the first char*/
|
||||
/*[↓] sort/put letters alphabetically.*/
|
||||
do length(xx); parse var xx char +1 xx; @.char=@.char || char; end
|
||||
/*reassemble word with sorted letters. */
|
||||
return @.a||@.b||@.c||@.d||@.e||@.f||@.g||@.h||@.i||@.j||@.k||@.l||@.m||,
|
||||
@.n||@.o||@.p||@.q||@.r||@.s||@.t||@.u||@.v||@.w||@.x||@.y||@.z
|
||||
|
|
|
|||
|
|
@ -1,28 +1,27 @@
|
|||
/*REXX program finds words with the largest set of anagrams (of the same size)*/
|
||||
iFID='unixdict.txt' /*the dictionary input File IDentifier.*/
|
||||
$=; !.=; #.=0; ww=0; uw=0; most=0 /*initialize a bunch of REXX variables.*/
|
||||
/* [↓] read the entire file (by lines)*/
|
||||
do while lines(iFID)\==0 /*Got any data? Then read a record. */
|
||||
@=space(linein(iFID),0) /*pick off a word from the input line. */
|
||||
LL=length(@); if LL<3 then iterate /*onesies and twosies (words) can't win*/
|
||||
if \datatype(@,'M') then iterate /*ignore any non─anagramable words. */
|
||||
uw=uw+1 /*count of the (useable) words in file.*/
|
||||
parse upper var @ _ +1 xx @. /*get uppercase @ and nullify @. */
|
||||
@._=_ /*get the first letter (special case). */
|
||||
/*[↓] sort/put letters alphabetically.*/
|
||||
do LL-1; parse var xx _ +1 xx; @._=@._||_; end /*get rest of word.*/
|
||||
/*reassemble word with sorted letters. */
|
||||
/*REXX program finds words with the largest set of anagrams (of the same size). */
|
||||
iFID= 'unixdict.txt' /*the dictionary input File IDentifier.*/
|
||||
$=; !.=; #.=0; ww=0; uw=0; most=0 /*initialize a bunch of REXX variables.*/
|
||||
/* [↓] read the entire file (by lines)*/
|
||||
do while lines(iFID)\==0 /*Got any data? Then read a record. */
|
||||
@=space( linein(iFID), 0) /*pick off a word from the input line. */
|
||||
LL=length(@); if LL<3 then iterate /*onesies and twosies (words) can't win*/
|
||||
if \datatype(@, 'M') then iterate /*ignore any non─anagramable words. */
|
||||
uw=uw+1 /*count of the (useable) words in file.*/
|
||||
parse upper var @ _ +1 xx @. /*get uppercase @ and nullify @. */
|
||||
@._=_ /*get the first letter (special case). */
|
||||
/*[↓] sort/put letters alphabetically.*/
|
||||
do LL-1; parse var xx _ +1 xx; @._=@._||_; end /*get the rest of the word.*/
|
||||
/*reassemble word with sorted letters. */
|
||||
zz=@.a||@.b||@.c||@.d||@.e||@.f||@.g||@.h||@.i||@.j||@.k||@.l||@.m||,
|
||||
@.n||@.o||@.p||@.q||@.r||@.s||@.t||@.u||@.v||@.w||@.x||@.y||@.z
|
||||
!.zz=!.zz @; #.zz=#.zz+1 /*append it to !.zz; bump the counter.*/
|
||||
if #.zz>most then do; $=zz; most=#.zz; if LL>ww then ww=LL; iterate; end
|
||||
if #.zz==most then $=$ zz /*append the sorted word──◄ $ anagrams.*/
|
||||
!.zz=!.zz @; #.zz=#.zz+1 /*append it to !.zz; bump the counter.*/
|
||||
if #.zz>most then do; $=zz; most=#.zz; if LL>ww then ww=LL; iterate; end
|
||||
if #.zz==most then $=$ zz /*append the sorted word──► $ anagrams.*/
|
||||
end /*while*/
|
||||
say '─────────────────────────' uw 'useable words in the dictionary file: ' iFID
|
||||
say '─────────────────────────' uw "useable words in the dictionary file: " iFID
|
||||
say
|
||||
do m=1 for words($); z=subword($,m,1) /*high count of anagrams.*/
|
||||
say ' ' left(subword(!.z,1,1),ww) ' [anagrams: ' subword(!.z,2)"]"
|
||||
end /*m*/ /*WW is the maximum width of any word.*/
|
||||
say
|
||||
say '───── Found' words($) "words (each of which have" #.z-1 'anagrams).'
|
||||
/*stick a fork in it, we're all done. */
|
||||
do m=1 for words($); z=subword($,m,1) /*the high count of the anagrams. */
|
||||
say ' ' left(subword(!.z, 1, 1), ww) " [anagrams: " subword(!.z,2)"]"
|
||||
end /*m*/ /*WW is the maximum width of any word.*/
|
||||
say /*stick a fork in it, we're all done. */
|
||||
say '───── Found' words($) "words (each of which have" #.z-1 'anagrams).'
|
||||
|
|
|
|||
|
|
@ -1,28 +1,27 @@
|
|||
/*REXX program finds words with the largest set of anagrams (of the same size)*/
|
||||
iFID='unixdict.txt' /*the dictionary input File IDentifier.*/
|
||||
$=; !.=; #.=0; ww=0; uw=0; most=0 /*initialize a bunch of REXX variables.*/
|
||||
/* [↓] read the entire file (by lines)*/
|
||||
do while lines(iFID)\==0 /*Got any data? Then read a record. */
|
||||
@=space(linein(iFID),0) /*pick off a word from the input line. */
|
||||
LL=length(@); if LL<3 then iterate /*onesies and twosies (words) can't win*/
|
||||
if \datatype(@,'M') then iterate /*ignore any non─anagramable words. */
|
||||
uw=uw+1 /*count of the (useable) words in file.*/
|
||||
parse upper var @ _ +1 xx '' @. /*get uppercase @ and nullify @. */
|
||||
@._=_ /*get the first letter (special case). */
|
||||
/*[↓] sort/put letters alphabetically.*/
|
||||
do LL-1; parse var xx _ +1 xx; @._=@._||_; end /*get rest of word.*/
|
||||
/*reassemble word with sorted letters. */
|
||||
zz=@.a||@.b||@.c||@.d||@.e||@.f||@.g||@.h||@.i||@.j||@.k||@.l||@.m||,
|
||||
@.n||@.o||@.p||@.q||@.r||@.s||@.t||@.u||@.v||@.w||@.x||@.y||@.z
|
||||
!.zz=!.zz @; #.zz=#.zz+1 /*append it to !.zz; bump the counter.*/
|
||||
if #.zz>most then do; $=zz; most=#.zz; if LL>ww then ww=LL; iterate; end
|
||||
if #.zz==most then $=$ zz /*append the sorted word──► $ anagrams.*/
|
||||
/*REXX program finds words with the largest set of anagrams (of the same size). */
|
||||
iFID= 'unixdict.txt' /*the dictionary input File IDentifier.*/
|
||||
$=; !.=; #.=0; ww=0; uw=0; most=0 /*initialize a bunch of REXX variables.*/
|
||||
/* [↓] read the entire file (by lines)*/
|
||||
do while lines(iFID)\==0 /*Got any data? Then read a record. */
|
||||
@=space( linein(iFID), 0) /*pick off a word from the input line. */
|
||||
LL=length(@); if LL<3 then iterate /*onesies and twosies (words) can't win*/
|
||||
if \datatype(@, 'M') then iterate /*ignore any non─anagramable words. */
|
||||
uw=uw+1 /*count of the (useable) words in file.*/
|
||||
parse upper var @ _ +1 xx . @. /*get uppercase @ and nullify @. */
|
||||
@._=_ /*get the first letter (special case). */
|
||||
/*[↓] sort/put letters alphabetically.*/
|
||||
do LL-1; parse var xx _ +1 xx; @._=@._ || _; end /*get rest of the word*/
|
||||
/*reassemble word with sorted letters. */
|
||||
zz=@.a|| @.b|| @.c|| @.d|| @.e|| @.f|| @.g|| @.h|| @.i|| @.j|| @.k|| @.l|| @.m ||,
|
||||
@.n|| @.o|| @.p|| @.q|| @.r|| @.s|| @.t|| @.u|| @.v|| @.w|| @.x|| @.y|| @.z
|
||||
!.zz=!.zz @; #.zz=#.zz+1 /*append it to !.zz; bump the counter.*/
|
||||
if #.zz>most then do; $=zz; most=#.zz; if LL>ww then ww=LL; iterate; end
|
||||
if #.zz==most then $=$ zz /*append the sorted word──► $ anagrams.*/
|
||||
end /*while*/
|
||||
say '─────────────────────────' uw 'useable words in the dictionary file: ' iFID
|
||||
say '─────────────────────────' uw 'useable words in the dictionary file: ' iFID
|
||||
say
|
||||
do m=1 for words($); z=subword($,m,1) /*high count of anagrams.*/
|
||||
say ' ' left(subword(!.z,1,1),ww) ' [anagrams: ' subword(!.z,2)"]"
|
||||
end /*m*/ /*WW is the maximum width of any word.*/
|
||||
say
|
||||
say '───── Found' words($) "words (each of which have" #.z-1 'anagrams).'
|
||||
/*stick a fork in it, we're all done. */
|
||||
do m=1 for words($); z=subword($, m, 1) /*the high count of the anagrams. */
|
||||
say ' ' left(subword(!.z, 1, 1), ww) " [anagrams: " subword(!.z, 2)']'
|
||||
end /*m*/ /*WW is the maximum width of any word.*/
|
||||
say /*stick a fork in it, we're all done. */
|
||||
say '───── Found' words($) "words (each of which have" #.z-1 'anagrams).'
|
||||
|
|
|
|||
|
|
@ -1,23 +1,23 @@
|
|||
u='Halloween' /*the word to be sorted by letter*/
|
||||
upper u /*fast method to uppercase a var.*/
|
||||
/*another: u = translate(u) */
|
||||
/*another: parse upper var u u */
|
||||
/*another: u = upper(u) */
|
||||
/*not always available [↑] */
|
||||
u= 'Halloween' /*word to be sorted by (Latin) letter.*/
|
||||
upper u /*fast method to uppercase a variable. */
|
||||
/*another: u = translate(u) */
|
||||
/*another: parse upper var u u */
|
||||
/*another: u = upper(u) */
|
||||
/*not always available [↑] */
|
||||
say 'u=' u
|
||||
_.=
|
||||
do until u=='' /*keep truckin' until U is null.*/
|
||||
parse var u y +1 u /*get the next (first) char in U.*/
|
||||
xx = '?'y /*assign a prefixed char to XX. */
|
||||
_.xx = _.xx || y /*append it to all the Y chars.*/
|
||||
end /*until*/ /*U now has the first char gone.*/
|
||||
/*Note: the var U is destroyed.*/
|
||||
do until u=='' /*keep truckin' until U is null. */
|
||||
parse var u y +1 u /*get the next (first) character in U.*/
|
||||
xx='?'y /*assign a prefixed character to XX. */
|
||||
_.xx=_.xx || y /*append it to all the Y characters. */
|
||||
end /*until*/ /*U now has the first character elided.*/
|
||||
/*Note: the variable U is destroyed.*/
|
||||
|
||||
/* [↓] build sorted letter word. */
|
||||
/* [↓] constructs a sorted letter word*/
|
||||
|
||||
z=_.?a||_.?b||_.?c||_.?d||_.?e||_.?f||_.?g||_.?h||_.?i||_.?j||_.?k||_.?l||_.?m||,
|
||||
_.?n||_.?o||_.?p||_.?q||_.?r||_.?s||_.?t||_.?u||_.?v||_.?w||_.?x||_.?y||_.?z
|
||||
|
||||
/*Note: the ? is prefixed to the letter to avoid */
|
||||
/*collisions with other REXX one-character variables.*/
|
||||
/*Note: the ? is prefixed to the letter to avoid */
|
||||
/*collisions with other REXX one-character variables.*/
|
||||
say 'z=' z
|
||||
|
|
|
|||
|
|
@ -1,16 +1,16 @@
|
|||
u='Halloween' /*the word to be sorted by letter*/
|
||||
upper u /*fast method to uppercase a var.*/
|
||||
L=length(u) /*get the length of the word. */
|
||||
u= 'Halloween' /*word to be sorted by (Latin) letter.*/
|
||||
upper u /*fast method to uppercase a variable. */
|
||||
L=length(u) /*get the length of the word (in bytes)*/
|
||||
say 'u=' u
|
||||
say 'L=' L
|
||||
_.=
|
||||
do k=1 for L /*keep truckin' for L chars. */
|
||||
parse var u =(k) y +1 /*get Kth character in U string. */
|
||||
xx = '?'y /*assign a prefixed char to XX. */
|
||||
_.xx = _.xx || y /*append it to all the Y chars.*/
|
||||
end /*do k*/ /*U now has the first char gone.*/
|
||||
do k=1 for L /*keep truckin' for L characters. */
|
||||
parse var u =(k) y +1 /*get the Kth character in U string.*/
|
||||
xx='?'y /*assign a prefixed character to XX. */
|
||||
_.xx=_.xx || y /*append it to all the Y characters. */
|
||||
end /*do k*/ /*U now has the first character elided.*/
|
||||
|
||||
/* [↓] build sorted letter word. */
|
||||
/* [↓] construct a sorted letter word.*/
|
||||
|
||||
z=_.?a||_.?b||_.?c||_.?d||_.?e||_.?f||_.?g||_.?h||_.?i||_.?j||_.?k||_.?l||_.?m||,
|
||||
_.?n||_.?o||_.?p||_.?q||_.?r||_.?s||_.?t||_.?u||_.?v||_.?w||_.?x||_.?y||_.?z
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue