ABC words: Difference between revisions
→{{header|Ring}}
(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
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.
2.
3.
4.
5.
6.
7.
8.
10.
11.
12.
13.
14.
15.
16.
17.
18.
19.
▲26. aminobenzoic
</pre>
|