Data commit
This commit is contained in:
parent
7387c8f97b
commit
cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions
9
Task/Averages-Mode/Groovy/averages-mode-1.groovy
Normal file
9
Task/Averages-Mode/Groovy/averages-mode-1.groovy
Normal file
|
|
@ -0,0 +1,9 @@
|
|||
def mode(Iterable col) {
|
||||
assert col
|
||||
def m = [:]
|
||||
col.each {
|
||||
m[it] = m[it] == null ? 1 : m[it] + 1
|
||||
}
|
||||
def keys = m.keySet().sort { -m[it] }
|
||||
keys.findAll { m[it] == m[keys[0]] }
|
||||
}
|
||||
6
Task/Averages-Mode/Groovy/averages-mode-2.groovy
Normal file
6
Task/Averages-Mode/Groovy/averages-mode-2.groovy
Normal file
|
|
@ -0,0 +1,6 @@
|
|||
def random = new Random()
|
||||
def sourceList = [ 'Lamp', 42.0, java.awt.Color.RED, new Date(), ~/pattern/]
|
||||
(0..10).each {
|
||||
def a = (0..10).collect { sourceList[random.nextInt(5)] }
|
||||
println "${mode(a)} == mode(${a})"
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue