Ordered words: Difference between revisions

Content added Content deleted
Line 3,547: Line 3,547:
=={{header|Ring}}==
=={{header|Ring}}==
<lang ring>
<lang ring>
load "stdlib.ring"
fn = "C:\Ring\unixdict.txt"


fp = fopen(fn,"r")
cStr = read("unixdict.txt")
wordList = str2list(cStr)
str = fread(fp, getFileSize(fp))
sum = 0
str = substr(str, windowsnl(), nl)
clist = str2list(str)
fclose(fp)
dlist = []


see "working..." + nl + nl
for m = 1 to len(clist)

flag = 1
for n = 1 to len(clist[m])-1
for n = 1 to len(wordList)
num = 0
if ascii(clist[m][n+1]) < ascii(clist[m][n])
len = len(wordList[n])-1
flag=0 exit ok
for m = 1 to len
asc1 = ascii(wordList[n][m])
asc2 = ascii(wordList[n][m+1])
if asc1 < asc2
num = num + 1
ok
next
next
if flag = 1
if num = len and len(wordList[n]) > 3
add(dlist, clist[m]) ok
sum = sum + 1
see "" + sum + ". " + wordList[n] + nl
next
ok

nr = 0
for m = 1 to len(dlist)
if len(dlist[m]) > nr
nr = len(dlist[m]) ok
next
next
see nl + "done..." + nl

for n = 1 to len(dlist)
if len(dlist[n]) = nr
see dlist[n] + nl ok
next

func getFileSize fp
c_filestart = 0
c_fileend = 2
fseek(fp,0,c_fileend)
nfilesize = ftell(fp)
fseek(fp,0,c_filestart)
return nfilesize
</lang>
</lang>
Output:
Output:
<pre>
<pre>
working...
abbott

accent
1. abel
accept
2. abet
access
3. abort
accost
4. aden
almost
5. adept
bellow
6. adopt
billow
7. aegis
biopsy
8. ahoy
chilly
9. ainu
choosy
10. airy
choppy
11. almost
effort
12. alps
floppy
13. amort
glossy
14. amos
knotty
15. arty
16. befit
17. begin
18. below
19. belt
20. bent
21. benz
22. bert
23. best
24. bevy
25. bhoy
26. biopsy
27. blot
28. blow
29. boxy
30. ceil
31. cent
32. chin
33. chip
34. chit
35. chop
36. chou
37. chow
38. city
39. clot
40. cloy
41. copy
42. cost
43. cosy
44. crux
45. cruz
46. deft
47. defy
48. deity
49. demo
50. dent
51. deny
52. dewy
53. dint
54. dirt
55. dirty
56. emory
57. empty
58. enos
59. envy
60. film
61. filmy
62. first
63. fist
64. flop
65. flow
66. flux
67. fort
68. forty
69. foxy
70. ghost
71. gilt
72. gimpy
73. gino
74. gist
75. glory
76. glow
77. gory
78. hilt
79. hint
80. host
81. klux
82. knot
83. know
84. knox
85. lost
86. mort
87. most

done...
</pre>
</pre>