Cody

# Problem 44779. Don't be mean. Be nice!

Solution 1668883

Submitted on 8 Nov 2018 by Binbin Qi
• Size: 28
• This is the leading solution.
This solution is locked. To view this solution, you need to provide a solution of the same size or smaller.

### Test Suite

Test Status Code Input and Output
1   Pass
R=1:4;k=2;y_correct = 27.5; a=dont_be_mean(R,k) assert(abs(a-y_correct)<1e-10)

a = 27.5000

2   Pass
R=0:8;k=3;y_correct = 493.3125; a=dont_be_mean(R,k) assert(abs(a-y_correct)<1e-10)

a = 493.3125

3   Pass
R=[1 2 4 6 8];k=4;y_correct = 4666.2; a=dont_be_mean(R,k) assert(abs(a-y_correct)<1e-10)

a = 4.6662e+03

4   Pass
R=[2 8 6 7 4 5];k=1;y_correct = 5.33333333333333; a=dont_be_mean(R,k) assert(abs(a-y_correct)<1e-10)

a = 5.3333

5   Pass
R=0:9; y=0; for k=1:8 y=y+dont_be_mean(R,k); end y_correct=61042519.44444444; assert(abs(y-y_correct)<1e-3)

### Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!
{"ft_lang_label":"__label__en","ft_lang_prob":0.59688574,"math_prob":0.9637675,"size":1118,"snap":"2021-04-2021-17","text_gpt3_token_len":417,"char_repetition_ratio":0.15260324,"word_repetition_ratio":0.0,"special_character_ratio":0.42844364,"punctuation_ratio":0.18021202,"nsfw_num_words":0,"has_unicode_error":false,"math_prob_llama3":0.9997309,"pos_list":[0],"im_url_duplicate_count":[null],"WARC_HEADER":"{\"WARC-Type\":\"response\",\"WARC-Date\":\"2021-01-17T19:40:30Z\",\"WARC-Record-ID\":\"<urn:uuid:439d6873-3e7a-4757-935e-8cc97ba97245>\",\"Content-Length\":\"84982\",\"Content-Type\":\"application/http; msgtype=response\",\"WARC-Warcinfo-ID\":\"<urn:uuid:e6817f26-e2f4-4e17-acfe-4dbfe393ebe0>\",\"WARC-Concurrent-To\":\"<urn:uuid:6b705ef1-28eb-41e4-b8e7-d80fabab2241>\",\"WARC-IP-Address\":\"23.223.252.57\",\"WARC-Target-URI\":\"https://uk.mathworks.com/matlabcentral/cody/problems/44779-don-t-be-mean-be-nice/solutions/1668883\",\"WARC-Payload-Digest\":\"sha1:6YBKKUYUWTSBYSDE56HQFI665UN7WWFU\",\"WARC-Block-Digest\":\"sha1:LDZQNXEEMTHJKMAZMJEKUWIDNPW6ME6T\",\"WARC-Identified-Payload-Type\":\"text/html\",\"warc_filename\":\"/cc_download/warc_2021/CC-MAIN-2021-04/CC-MAIN-2021-04_segments_1610703513144.48_warc_CC-MAIN-20210117174558-20210117204558-00732.warc.gz\"}"}