Add tasks for all the new languages
This commit is contained in:
parent
9dc3c2bb62
commit
bba7bfd280
13208 changed files with 134745 additions and 0 deletions
13
Task/Averages-Mode/Wren/averages-mode.wren
Normal file
13
Task/Averages-Mode/Wren/averages-mode.wren
Normal file
|
|
@ -0,0 +1,13 @@
|
|||
class Arithmetic {
|
||||
static mode(arr) {
|
||||
var map = {}
|
||||
for (e in arr) {
|
||||
if (map[e] == null) map[e] = 0
|
||||
map[e] = map[e] + 1
|
||||
}
|
||||
var max = map.values.reduce {|x, y| x > y ? x : y}
|
||||
return map.keys.where {|x| map[x] == max}.toList
|
||||
}
|
||||
}
|
||||
|
||||
System.print(Arithmetic.mode([1,2,3,4,5,5,51,2,3]))
|
||||
Loading…
Add table
Add a link
Reference in a new issue