Compare the averages of my lists

Mathematica, 15 bytes

Order@@Mean/@#&

Try it online!

Function which expects a list of two lists. Mean/@# takes the arithmetic mean of each list in the input, then those means are passed into Order, which returns -1 if the first list wins, 0 if there is a tie, and 1 if the second list wins.


JavaScript (ES6), 52 50 bytes

(Saved 2 bytes thanks to @Shaggy.)

Here are two 50-byte solutions:

f=(N,M,a=eval(N.join`+`)/N.length)=>M?(a-f(M))/0:a

(N,M,A=a=>eval(a.join`+`)/a.length)=>(A(N)-A(M))/0

Returns Infinity for N, -Infinity for M, and NaN for a tie.

The first solution may require a bit of explanation due to the recursion:

On the first call to the function, a is initialized as the average of the N array:

a=eval(N.join`+`)/N.length

M has a value at this point, so the first part of the conditional expression is called:

M ? (a-f(M))/0 : a  ----------    

The function is called within this expression, this time substituting M for N.

On this second call to the function, a is initialized as the average of N –– which was M in the previous call.

Since there is no second parameter during this call to the function, the second part of the conditional expression is triggered, which returns the average:

M ? (a-f(M))/0 : a  --

We can now understand the expression better:

(a - f(M)) / 0

It's:

(the average of N  minus  the average of M) divided by 0

The difference between the averages will be a positive number, a negative number, or 0.

Dividing the difference by 0 results in Infinity, -Infinity, or NaN – providing the three distinct values as required.

Test Cases:

f=(N,M,a=eval(N.join`+`)/N.length)=>M?(a-f(M))/0:a

console.log(f([7], [6]                 )) // N wins  (N has 7, M has 6 )
console.log(f([4,5], [4,4]             )) // N wins  (N has 4.5, M has 4)
console.log(f([2,3,4], [4,5,6]         )) // M wins  (N has 3, M has 5)
console.log(f([4,1,3], [7,3,2,1,1,2]   )) // Tie     (both have 2.666...)
console.log(f([100,390,1], [89,82,89]  )) // N wins  (N has 163.666..., M has 86.666...)
console.log(f([92,892], [892,92]       )) // Tie     (lists are basically identical) 
console.log(f([10,182], [12,78,203,91] )) // Tie     (both have 96)


Mathematica, 21 bytes

Sign[Mean@#-Mean@#2]&

1 for # wins, -1 for #2 wins, 0 for tie.