Идея с сортировкой букв в слове гениальна . Пока искал как их сортировать, нашелся готовый скрипт —
setbatchlines,-1
listlines,off
#noenv
dictionary=
(
скрипт
колба
бокал
форум
приказ
каприз
анаграмма
)
dict:=[]
Loop, Parse, dictionary, `n, `r ; Put all words in an array dict, at dict[wordLength, wordLettersSorted, entryNumber]
{
keyword:=A_LoopField
len:=strlen(A_LoopField)
keyword:=Ltrim(RegExReplace(keyword,"(.)",",$1"),",")
Sort,keyword,D, ; Make a keyword, eg, Dallas -> a,a,D,l,l,s
if !IsObject(dict[len,keyword])
dict[len,keyword]:=[]
dict[len,keyword].push(A_LoopField) ; Put the word in the keyword slot, all permutations will get the same keyword and end up in this slot
}
allAnagrams:=[]
for len, lengthGroup in dict {
for keyword, anagrams in lengthGroup
if (anagrams.length()>1) ; For each keyword which has more than entry, there is anagrams, save those
allAnagrams.push(anagrams)
}
str:="Anagram list:`n" ; Print result
for k, anagrams in allAnagrams {
str.= "Anagram set`t" k ":`t"
for l, anagram in anagrams
str.=anagram "`t"
str.= "`n"
}
gui, font,,courier new ; Show result
gui,add,edit,w1000 r40, % str
gui,show