Are the beams above or below the notes?
R, 40 bytes
function(x)min(x)+max(x)+mean(sign(x))<0
Try it online!
If min(x)+max(x)
is non-zero, its sign corresponds to the note farthest from the centre and gives the direction of the beam.
Adding mean(sign(x))
can never change the sign. Indeed, either (a) all notes are of the same sign and mean(sign(x))
is of the same sign as min(x)+max(x)
or (b) notes are of both signs and mean(sign(x))
is strictly in \$(-1,1)\$ whereas min(x)+max(x)
is an integer, so the sign of the sum is unchanged.
If min(x)+max(x)==0
, the sign of the mean decides the direction.
If undecided, defaults to FALSE
.
Python 3, 55 bytes
lambda a:(min(a)+max(a)or sum((i>0)-(i<0)for i in a))<0
Try it online!
JavaScript (ES6), 66 64 bytes
a=>(a.map(m=v=>(k+=v>0||-!!v,a=v>a?a:v,m=v<m?m:v),k=0)|a+m||k)<0
Try it online!
Commented
a => ( // a[] = input array, re-used to store the minimum value
a.map(m = // initialize m = maximum to a non-numeric value
v => ( // for each value v in a[]:
k += // update k:
v > 0 || // increment it if v > 0
-!!v, // decrement it if v < 0
a = v > a ? a : v, // update a to min(a, v) (always v if a is non-numeric)
m = v < m ? m : v // update m to max(m, v) (always v if m is non-numeric)
), //
k = 0 // start with k = 0
) // end of map()
| a + m // use a + m if it's not equal to 0
|| k // otherwise, use k
) < 0 // test if the above value is negative