ABC words: Difference between revisions

(Created page with "{{draft task}} A word is ABC word if "a", "b" and "c" letters appear in alphabetical order. =={{header|Ring}}== <lang ring> cStr = read("unixdict.txt") wordList = str2list(c...")
 
Line 11:
 
for n = 1 to len(wordList)
cnt1 = count(wordList[n],"a")
cnt2 = count(wordList[n],"b")
cnt3 = count(wordList[n],"c")
bool1 = substr(wordList[n],"a")
bool2 = substr(wordList[n],"b")
Line 16 ⟶ 19:
bool4 = bool1 > 0 and bool2 > 0 and bool3 > 0
bool5 = bool2 > bool1 and bool3 > bool2
ifcnt bool4= (cnt1 = 1) and (cnt2 = 1) and bool5(cnt3 = 1)
if bool4 = 1 and bool5 = 1 and cnt
num = num + 1
see "" + num + ". " + wordList[n] + nl
ok
next
 
func count(cString,dString)
sum = 0
while substr(cString,dString) > 0
sum++
cString = substr(cString,substr(cString,dString)+len(string(sum)))
end
return sum
</lang>
Output:
<pre>
ABC words are:
1. abackabc
2. abacusabduct
3. abcabject
4. abdicateabscess
5. abductabsence
6. abeyanceaerobic
7. abjectalberich
8. abreactalbrecht
269. aminobenzoic
9. abscess
10. abscissadiabetic
11. abscissaediabolic
12. absencefabric
13. abstractiambic
14. abstractermetabolic
15. abstractornabisco
16. adiabaticroadblock
17. aerobacterstrabismic
18. aerobicsyllabic
19. albacoretablecloth
20. alberich
21. albrecht
22. algebraic
23. alphabetic
24. ambiance
25. ambuscade
26. aminobenzoic
27. anaerobic
28. arabic
29. athabascan
30. auerbach
31. diabetic
32. diabolic
33. drawback
34. fabric
35. fabricate
36. flashback
37. halfback
38. iambic
39. lampblack
40. leatherback
41. metabolic
42. nabisco
43. paperback
44. parabolic
45. playback
46. prefabricate
47. quarterback
48. razorback
49. roadblock
50. sabbatical
51. snapback
52. strabismic
53. syllabic
54. tabernacle
55. tablecloth
</pre>
2,468

edits