Anagrams: Difference between revisions
Content added Content deleted
Alextretyak (talk | contribs) m (→{{header|11l}}) |
|||
Line 1,975: | Line 1,975: | ||
=={{header|Elena}}== |
=={{header|Elena}}== |
||
ELENA |
ELENA 4.0: |
||
<lang elena>// Two or more words can be composed of the same characters, but in |
|||
⚫ | |||
// a different order. Using the word list at |
|||
⚫ | |||
// http://www.puzzlers.org/pub/wordlists/unixdict.txt, find the sets of words |
|||
⚫ | |||
// that share the same characters that contain the most words in them. |
|||
⚫ | |||
⚫ | |||
import |
import system'routines; |
||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
extension op |
extension op |
||
{ |
{ |
||
string normalized() |
|||
= self |
= self.toArray().ascendant().summarize(new StringWriter()); |
||
} |
} |
||
public program |
public program() |
||
{ |
|||
[ |
|||
auto |
auto dictionary := new Map<string,object>(); |
||
File |
File.assign("unixdict.txt").forEachLine:(word) |
||
{ |
|||
var s := aWord. |
|||
var |
var key := word.normalized(); |
||
var |
var item := dictionary[key]; |
||
if (nil == |
if (nil == item) |
||
{ |
|||
item := new ArrayList(); |
|||
dictionary[key] := item |
|||
}; |
|||
item.append:word |
|||
}; |
|||
dictionary.Values |
|||
aDictionary values; |
|||
sort |
.sort:(former,later => former.Item2.Length > later.Item2.Length ) |
||
top:20 |
.top:20 |
||
.forEach:(pair){ console.printLine(pair.Item2) }; |
|||
console |
console.readChar() |
||
}</lang> |
|||
{{out}} |
{{out}} |
||
<pre> |
<pre> |