Teacup rim text: Difference between revisions
Content added Content deleted
m (→{{header|REXX}}: added/changed some comments.) |
(→{{header|Go}}: Updated to exclude duplicates etc.) |
||
Line 74: | Line 74: | ||
words := readWords("mit_10000.txt") // using local copy |
words := readWords("mit_10000.txt") // using local copy |
||
n := len(words) |
n := len(words) |
||
used := make(map[string]bool) |
|||
outer: |
outer: |
||
for _, word := range words { |
for _, word := range words { |
||
Line 81: | Line 82: | ||
rotate(runes) |
rotate(runes) |
||
word2 := string(runes) |
word2 := string(runes) |
||
if word == word2 || used[word2] { |
|||
continue outer |
|||
} |
|||
ix := sort.SearchStrings(words, word2) |
ix := sort.SearchStrings(words, word2) |
||
if ix == n || words[ix] != word2 { |
if ix == n || words[ix] != word2 { |
||
Line 86: | Line 90: | ||
} |
} |
||
variants = append(variants, word2) |
variants = append(variants, word2) |
||
} |
|||
for _, variant := range variants { |
|||
used[variant] = true |
|||
} |
} |
||
fmt.Println(variants) |
fmt.Println(variants) |
||
Line 93: | Line 100: | ||
{{out}} |
{{out}} |
||
<pre> |
<pre> |
||
[aaa aaa aaa] |
|||
[aim ima mai] |
[aim ima mai] |
||
[arc rca car] |
[arc rca car] |
||
[asp spa pas] |
[asp spa pas] |
||
[ate tea eat] |
[ate tea eat] |
||
[car arc rca] |
|||
[eat ate tea] |
|||
[iii iii iii] |
|||
[ima mai aim] |
|||
[ips psi sip] |
[ips psi sip] |
||
[mai aim ima] |
|||
[ooo ooo ooo] |
|||
[pas asp spa] |
|||
[psi sip ips] |
|||
[rca car arc] |
|||
[sip ips psi] |
|||
[spa pas asp] |
|||
[tea eat ate] |
|||
[www www www] |
|||
[xxx xxx xxx] |
|||
</pre> |
</pre> |
||