Cody

# Problem 568. Number of 1s in a binary string

Solution 2228428

Submitted on 22 Apr 2020 by Jyothsna Chintala
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
x = '0000'; y_correct = 0; assert(isequal(one(x),y_correct));

count = 0 y = 0

2   Pass
x = '111'; y_correct = 3; assert(isequal(one(x),y_correct));

count = 0 count = 1 count = 2 count = 3 y = 3

3   Pass
x = '1100101'; y_correct = 4; assert(isequal(one(x),y_correct));

count = 0 count = 1 count = 2 count = 3 count = 4 y = 4

### 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.6840448,"math_prob":0.99690354,"size":696,"snap":"2021-04-2021-17","text_gpt3_token_len":215,"char_repetition_ratio":0.17919075,"word_repetition_ratio":0.14285715,"special_character_ratio":0.36925286,"punctuation_ratio":0.124087594,"nsfw_num_words":0,"has_unicode_error":false,"math_prob_llama3":0.9983202,"pos_list":[0],"im_url_duplicate_count":[null],"WARC_HEADER":"{\"WARC-Type\":\"response\",\"WARC-Date\":\"2021-01-20T06:37:31Z\",\"WARC-Record-ID\":\"<urn:uuid:0cc2d06d-c17c-4f4b-916e-61a1f9bf283c>\",\"Content-Length\":\"79270\",\"Content-Type\":\"application/http; msgtype=response\",\"WARC-Warcinfo-ID\":\"<urn:uuid:60d196b2-4d99-448d-828e-42826073a69f>\",\"WARC-Concurrent-To\":\"<urn:uuid:6d082e65-00ae-4588-b850-8e8a102fe215>\",\"WARC-IP-Address\":\"96.7.70.236\",\"WARC-Target-URI\":\"https://nl.mathworks.com/matlabcentral/cody/problems/568-number-of-1s-in-a-binary-string/solutions/2228428\",\"WARC-Payload-Digest\":\"sha1:SQYKVGLNAHGCF7OFFPPH2VBTVPWC2WWE\",\"WARC-Block-Digest\":\"sha1:NDBLGYF3Z7D37ZYXIY2VDC6B4F7V6V2F\",\"WARC-Identified-Payload-Type\":\"text/html\",\"warc_filename\":\"/cc_download/warc_2021/CC-MAIN-2021-04/CC-MAIN-2021-04_segments_1610703519923.26_warc_CC-MAIN-20210120054203-20210120084203-00518.warc.gz\"}"}