Anagrams: Difference between revisions

Content added Content deleted
(Add Groovy)
Line 166: Line 166:
def groups = words.groupBy{ it.toList().sort() }
def groups = words.groupBy{ it.toList().sort() }
def bigGroupSize = groups.collect{ it.value.size() }.max()
def bigGroupSize = groups.collect{ it.value.size() }.max()
println groups.findAll{ it.value.size() == bigGroupSize }.collect{ it.value }.collect{ it.join(' ') }.join('\n')
def bigAnagrams = { it.value.size() == bigGroupSize }
println groups.findAll(bigAnagrams).collect{ it.value }.collect{ it.join(' ') }.join('\n')</lang>
</lang>
produces this output:
produces this output:
<pre>
<pre>