Find words which contain the most consonants: Difference between revisions

From Rosetta Code
Content added Content deleted
 
No edit summary
Line 1: Line 1:
{{Draft task}}
#REDIRECT [[User talk:CalmoSoft/Find words which contains most consonants]]

;Task:
Use the dictionary  [https://web.archive.org/web/20180611003215/http://www.puzzlers.org/pub/wordlists/unixdict.txt unixdict.txt]

Find the words which contains most consonants,   but each consonant should appear only once in a word.

The length of any word shown should have a length &nbsp; <big>'''>&nbsp; 10</big>.

=={{header|Ring}}==
<lang ring>
load "stdlib.ring"

cStr = read("unixdict.txt")
wordList = str2list(cStr)
consonants = []
result = []
num = 0

see "working..." + nl

ln = len(wordList)
for n = ln to 1 step -1
if len(wordList[n]) < 11
del(wordList,n)
ok
next

for n = 1 to len(wordList)
flag = 1
numcon = 0
str = wordList[n]
for m = 1 to len(str) - 1
for p = m+1 to len(str)
if not isvowel(str[m]) and (str[m] = str[p])
flag = 0
exit 2
ok
next
next
if flag = 1
add(consonants,wordList[n])
ok
next

for n = 1 to len(consonants)
con = 0
str = consonants[n]
for m = 1 to len(str)
if not isvowel(str[m])
con = con + 1
ok
next
add(result,[consonants[n],con])
next

result = sort(result,2)
result = reverse(result)

for n = 1 to len(result)
see "" + n + ". " + result[n][1] + " " + result[n][2] + nl
next

see "done..." + nl
</lang>
{{out}}
<pre>
working...
1. comprehensible 9
2. indecipherable 8
3. boustrophedon 8
4. bricklaying 8
5. demonstrable 8
6. chemisorption 8
7. indecomposable 8
8. indiscoverable 8
9. discriminable 8
10. shipbuilding 8
....
50. deliquescent 7
51. inscrutable 7
52. declamatory 7
53. decomposition 7
54. decomposable 7
55. leatherback 7
56. exclusionary 7
57. convertible 7
58. exculpatory 7
59. loudspeaking 7
60. consumptive 7
...
180. eigenvector 6
181. exceptional 6
182. archipelago 6
183. anisotropic 6
184. encapsulate 6
185. evolutionary 6
186. elizabethan 6
187. declaration 6
188. declarative 6
189. declamation 6
190. comparative 6
...
330. equilibrium 5
331. equinoctial 5
332. onomatopoeic 5
333. inequitable 5
334. requisition 5
335. diatomaceous 5
336. homogeneous 5
337. radioactive 5
338. deleterious 5
339. inoperative 5
340. inquisitive 5
....
345. audiovisual 4
346. onomatopoeia 4
347. bourgeoisie 4
done...
</pre>

Revision as of 09:44, 15 February 2021

Find words which contain the most consonants is a draft programming task. It is not yet considered ready to be promoted as a complete task, for reasons that should be found in its talk page.
Task

Use the dictionary  unixdict.txt

Find the words which contains most consonants,   but each consonant should appear only once in a word.

The length of any word shown should have a length   >  10.

Ring

<lang ring> load "stdlib.ring"

cStr = read("unixdict.txt") wordList = str2list(cStr) consonants = [] result = [] num = 0

see "working..." + nl

ln = len(wordList) for n = ln to 1 step -1

   if len(wordList[n]) < 11
      del(wordList,n)
   ok

next

for n = 1 to len(wordList)

   flag = 1
   numcon = 0
   str = wordList[n]
   for m = 1 to len(str) - 1
       for p = m+1 to len(str)
           if not isvowel(str[m]) and (str[m] = str[p])
              flag = 0
              exit 2
           ok
       next
   next 
   if flag = 1
      add(consonants,wordList[n])
   ok

next

for n = 1 to len(consonants)

   con = 0
   str = consonants[n]
   for m = 1 to len(str)
       if not isvowel(str[m])
          con = con + 1
       ok
   next
   add(result,[consonants[n],con])

next

result = sort(result,2) result = reverse(result)

for n = 1 to len(result)

   see "" + n + ". " + result[n][1] + " " + result[n][2] + nl

next

see "done..." + nl </lang>

Output:
working...
1. comprehensible 9
2. indecipherable 8
3. boustrophedon 8
4. bricklaying 8
5. demonstrable 8
6. chemisorption 8
7. indecomposable 8
8. indiscoverable 8
9. discriminable 8
10. shipbuilding 8
....
50. deliquescent 7
51. inscrutable 7
52. declamatory 7
53. decomposition 7
54. decomposable 7
55. leatherback 7
56. exclusionary 7
57. convertible 7
58. exculpatory 7
59. loudspeaking 7
60. consumptive 7
...
180. eigenvector 6
181. exceptional 6
182. archipelago 6
183. anisotropic 6
184. encapsulate 6
185. evolutionary 6
186. elizabethan 6
187. declaration 6
188. declarative 6
189. declamation 6
190. comparative 6
...
330. equilibrium 5
331. equinoctial 5
332. onomatopoeic 5
333. inequitable 5
334. requisition 5
335. diatomaceous 5
336. homogeneous 5
337. radioactive 5
338. deleterious 5
339. inoperative 5
340. inquisitive 5
....
345. audiovisual 4
346. onomatopoeia 4
347. bourgeoisie 4
done...