Week 3 Exercise 67 -

199 views
Skip to first unread message

gmy5011

unread,
Apr 11, 2016, 6:18:21 PM4/11/16
to mooc.fi
Hi,

I'm having problems with week 3 exercise 67.

I am getting a 50% successful on this exercise. Tes 1 and 2 pass, but test 3 and 4 fail. I have checked the variance of the list of numbers ([1,3] and [2,9,1,3,5]) that are failing, but my code returns the correct variance number. SO I am not sure what is going on.

"The method should be called only once!
When variance was called with list [1,3] java.lang.AssertionError:
Unexpected method call Variance.average([1, 3]):
Variance.average([1, 3]): expected: 1, actual: 2"

"The method should be called only once!
When variance was called with list [2,9,1,3,5] java.lang.AssertionError:
Unexpected method call Variance.average([2, 9, 1, 3, 5]):
Variance.average([2, 9, 1, 3, 5]): expected: 1, actual: 2"
     
    

Best regards,

gmy5011

Jarmo Isotalo

unread,
Apr 12, 2016, 5:36:14 AM4/12/16
to gmy5011, mooc.fi
So you should calculate the average for the list just once (per call to the variance). So move it out of the loop.

-Jarmo

--
http://mooc.fi
---
You received this message because you are subscribed to the Google Groups "mooc.fi" group.
To unsubscribe from this group and stop receiving emails from it, send an email to moocfi+un...@googlegroups.com.
To post to this group, send email to moo...@googlegroups.com.
Visit this group at https://groups.google.com/group/moocfi.
To view this discussion on the web visit https://groups.google.com/d/msgid/moocfi/3034a949-90d8-4617-b94e-33df9fb5733b%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

gmy...@gmail.com

unread,
Apr 12, 2016, 6:23:50 PM4/12/16
to mooc.fi, gmy...@gmail.com
Thank you for the help on both my problems! 
Reply all
Reply to author
Forward
0 new messages