Anagrams: Difference between revisions

1,289 bytes added ,  5 years ago
no edit summary
m (→‎{{header|Ring}}: Remove vanity tags)
No edit summary
Line 7,371:
[EILV] evil, levi, live, veil, vile
</PRE>
 
=={{header|Yabasic}}==
<lang Yabasic>filename$ = "unixdict.txt"
maxw = 0 : c = 0 : dimens(c)
i = 0
dim p(100)
 
if (not open(1,filename$)) error "Could not open '"+filename$+"' for reading"
 
print "Be patient, please ...\n"
 
while(not eof(1))
line input #1 a$
c = c + 1
p$(c) = a$
po$(c) = sort$(lower$(a$))
count = 0
head = 0
insert(1)
if not(mod(c, 10)) dimens(c)
wend
 
for n = 1 to i
nw = p(n)
repeat
print p$(nw)," ";
nw = d(nw,2)
until(not nw)
print
next n
 
print "\n", peek("secondsrunning"), " sec"
 
sub sort$(a$)
local n, i, t$, c1$, c2$
for n = 1 to len(a$) - 1
for i = n + 1 to len(a$)
c1$ = mid$(a$, n, 1) : c2$ = mid$(a$, i, 1)
if c1$ > c2$ then
t$ = c1$
c1$ = c2$
c2$ = t$
mid$(a$, n, 1) = c1$ : mid$(a$, i, 1) = c2$
end if
next i
next n
return a$
end sub
 
sub dimens(c)
redim p$(c + 10)
redim po$(c + 10)
redim d(c + 10, 3)
end sub
 
sub insert(j)
local p
if po$(c) < po$(j) then
p = 1
elseif po$(c) = po$(j) then
p = 2
if count = 0 head = j
count = count + 1
if count > maxw then
i = 1
p(i) = head
maxw = count
elseif count = maxw then
i = i + 1
p(i) = head
end if
else
p = 3
end if
if d(j,p) then
insert(d(j,p))
else
d(j,p) = c
end if
end sub</lang>
 
=={{header|zkl}}==
672

edits