Changeable words: Difference between revisions
Content added Content deleted
(Added Java solution) |
m (→{{header|REXX}}: elided a duplicate filter for the words, changed whitespace, moved an assignment statement.) |
||
Line 873: | Line 873: | ||
say copies('─', 30) # "words ("wc 'usable words) in the dictionary file: ' iFID |
say copies('─', 30) # "words ("wc 'usable words) in the dictionary file: ' iFID |
||
⚫ | |||
abc= 'abcdefghijklmnopqrstuvwxyz'; upper abc /*alphabet ordered by frequency of use.*/ |
abc= 'abcdefghijklmnopqrstuvwxyz'; upper abc /*alphabet ordered by frequency of use.*/ |
||
Labc= length(abc) /*the length of the alphabet to be used*/ |
Labc= length(abc) /*the length of the alphabet to be used*/ |
||
⚫ | |||
do j=1 for wc; L= length($.j) /*process all the words that were found*/ |
do j=1 for wc; L= length($.j) /*process all the words that were found*/ |
||
if \datatype($.j, 'M') then iterate /*verify that the word is all letters. */ |
|||
x= $.j; upper x /*get an uppercased version of the word*/ |
x= $.j; upper x /*get an uppercased version of the word*/ |
||
pad= left('', 9) /*PAD: used for indenting the output.*/ |
pad= left('', 9) /*PAD: used for indenting the output.*/ |
||
do k=1 for L; y= substr(x, k, 1) /*Y: the current letter being changed.*/ |
|||
do c=1 for Labc /* [↓] change the Y letter to another.*/ |
|||
?= substr(abc, c, 1) /*get a new char to replace one in word*/ |
|||
if ?==y then iterate /*Is this the same char? Then use next*/ |
|||
new= overlay(?, x, k); upper new /*create a spanking new (changed) word.*/ |
|||
if @.new=='' then iterate /*if the new word isn't a word, skip it*/ |
|||
finds= finds + 1 /*bump count of changeable words found.*/ |
|||
say pad left($.j, 30) @.new /*indent original word for readability.*/ |
|||
end /*c*/ |
|||
end /*k*/ |
|||
end |
end /*j*/ |
||
say copies('─', 30) finds ' changeable words found with a minimum length of ' minL</lang> |
say copies('─', 30) finds ' changeable words found with a minimum length of ' minL</lang> |
||
{{out|output|text= when using the default inputs:}} |
{{out|output|text= when using the default inputs:}} |