Odd words: Difference between revisions

Content added Content deleted
(Added Java solution)
m (→‎version 2, caseless: adjusted the record count.)
Line 713: Line 713:
$.#= x; upper x; @.x= . /*save: original case and the semaphore*/
$.#= x; upper x; @.x= . /*save: original case and the semaphore*/
end /*#*/ /* [↑] semaphore name is uppercased. */
end /*#*/ /* [↑] semaphore name is uppercased. */
#= # - 1
minW= minL * 2 - 1 /*minimum width of a word to be usable.*/
minW= minL * 2 - 1 /*minimum width of a word to be usable.*/
say copies('─', 30) # "words in the dictionary file: " iFID
say copies('─', 30) # "words in the dictionary file: " iFID
ows= 0 /*count of the "odd words" found. */
ows= 0 /*count of the "odd words" found. */
do j=1 for #-1; L= length($.j) /*process all the words that were found*/
do j=1 for #; L= length($.j) /*process all the words that were found*/
if L<minW then iterate /*Is word too short? Then ignore it. */
if L<minW then iterate /*Is word too short? Then ignore it. */
ow= /*initialize the "odd word". */
ow= /*initialize the "odd word". */
Line 727: Line 728:
say right(left($.j, 20), 24) left(ow, 9) /*indent original word for readability.*/
say right(left($.j, 20), 24) left(ow, 9) /*indent original word for readability.*/
end /*j*/
end /*j*/
say copies('─', 30) ows ' "odd words" found with a minimum length of ' minL</lang>
say copies('─', 30) ows ' "odd words" found with a minimum length of ' minL
</lang>
{{out|output|text=&nbsp; when using the default input:}}
{{out|output|text=&nbsp; when using the default input:}}
<pre>
<pre>
────────────────────────────── 25105 words in the dictionary file: unixdict.txt
────────────────────────────── 25104 words in the dictionary file: unixdict.txt
barbarian brain
barbarian brain
childbear cider
childbear cider