MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi test

Learn moreOpportunities for recent engineering grads.

Apply TodayGiven two lists of numbers, determine the weighted average.

Example

[1 2 3] and [10 15 20]

should result in

33.3333 (1*10 + 2*15 + 3*20)/3

3843 correct solutions
2917 incorrect solutions

Last solution submitted on Nov 30, 2015

4 players like this problem

1 player likes this solution

1 Comment

Siva Madugula
on 3 Nov 2015 at 9:13

That's good.

1 Comment

Kevin Lamb
on 30 Sep 2015

how the heck can you get smaller than?
y = x*w'/3

1 Comment

Alexander Wickstrom
on 28 May 2015

Sweet.

1 Comment

Hugo
on 2 Apr 2015

obviously misuse of poor testing...

1 Comment

Christian
on 4 Mar 2015

Easy, but not the weighted average. Even assuming that the first vector contains the weighting factors (for example the sizes of different sample groups) and the second vector contains the means of the sample groups, than the divisor has to be the sum of the weighting factors instead of the number.

1 Comment

Giorgos Papakonstantinou
on 5 Mar 2014

This is not the weighted average

1 Comment

!ntel
on 8 Oct 2013

Good one

1 Comment

david
on 6 Sep 2013

odd name

1 player likes this solution

1 Comment

Randall Stace Romero Aguilar
on 23 Aug 2013

I think the problem is not well formulated: in a weighted average, your weights should add up to one

1 Comment

Frequency Domain
on 24 Jul 2013

FP operations and isequal(), sometimes yield some bitter results

1 Comment

sea knowledge
on 13 Dec 2012

l doubt on this definition of the problem

1 Comment

J-G van der Toorn
on 11 Sep 2012

This is not the Weighted average. One should divide by the sum of the weighs, not by the number of them.

1 Comment

Dimosthenis
on 20 Jul 2012

This is not the weighted average.
The weighted average has the sum of w in the denominator

1 Comment

Andrew Davis
on 2 Mar 2012

This probably shouldn't pass...

8 Comments