RosettaCodeData/Task/Anagrams/EasyLang/anagrams.easy
2025-06-11 20:16:52 -04:00

46 lines
744 B
Text

global name$[] cnt[] .
func n2id n$ .
for id to len name$[] : if name$[id] = n$ : return id
name$[] &= n$
cnt[] &= 0
return id
.
func norm s$ .
d$[] = strchars s$
for i = 1 to len d$[] - 1
for j = i + 1 to len d$[]
if strcode d$[j] < strcode d$[i] : swap d$[j] d$[i]
.
.
n$ = strjoin d$[] ""
return n2id n$
.
repeat
s$ = input
until s$ = ""
id = norm s$
cnt[id] += 1
max = higher max cnt[id]
w$[] &= s$
wid[] &= id
.
for id to len name$[]
if cnt[id] = max
for i to len w$[]
if wid[i] = id : write w$[i] & " "
.
print ""
.
.
#
# a few lines of unixdict.txt, also works with all
input_data
abe
abed
abel
ablaze
able
ablution
angel
angle
angles