Teacup rim text: Difference between revisions
Content deleted Content added
Alpha bravo (talk | contribs) Added AutoHotkey |
|||
Line 67: | Line 67: | ||
ate -> tea -> eat |
ate -> tea -> eat |
||
</pre> |
</pre> |
||
=={{header|AutoHotkey}}== |
|||
<lang AutoHotkey>Teacup_rim_text(wList){ |
|||
oWord := [], oRes := [], n := 0 |
|||
for i, w in StrSplit(wList, "`n", "`r") |
|||
if StrLen(w) >= 3 |
|||
oWord[StrLen(w), w] := true |
|||
for l, obj in oWord |
|||
{ |
|||
for w, bool in obj |
|||
{ |
|||
loop % l |
|||
if oWord[l, rotate(w)] |
|||
{ |
|||
oWord[l, w] := 0 |
|||
if (A_Index = 1) |
|||
n++, oRes[n] := w |
|||
if (A_Index < l) |
|||
oRes[n] := oRes[n] "," (w := rotate(w)) |
|||
} |
|||
if (StrSplit(oRes[n], ",").Count() <> l) |
|||
oRes.RemoveAt(n) |
|||
} |
|||
} |
|||
return oRes |
|||
} |
|||
rotate(w){ |
|||
return SubStr(w, 2) . SubStr(w, 1, 1) |
|||
}</lang> |
|||
Examples:<lang AutoHotkey>FileRead, wList, % A_Desktop "\unixdict.txt" |
|||
result := "" |
|||
for i, v in Teacup_rim_text(wList) |
|||
result .= v "`n" |
|||
MsgBox % result |
|||
return</lang> |
|||
{{out}} |
|||
<pre>apt,pta,tap |
|||
arc,rca,car |
|||
ate,tea,eat</pre> |
|||
=={{header|AWK}}== |
=={{header|AWK}}== |