Cody

Problem 43676. Count the Digits in the Box

Solution 2589739

Submitted on 20 Jun 2020
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   Fail
extras = 22222; censusIn = getDigitCensus(extras) str = string(censusIn); censusOut = histc(char([str{:}]+string(extras))-48,0:9)+1; assert(isequal(censusIn,censusOut))

test = 0 1 2 3 4 5 6 7 8 9 50 50 50 50 50 censusIn = 0 0 0 0 0 0 0 0 0 0

Assertion failed.

2   Fail
extras = 6380059; censusIn = getDigitCensus(extras) str = string(censusIn); censusOut = histc(char([str{:}]+string(extras))-48,0:9)+1; assert(isequal(censusIn,censusOut))

test = 0 1 2 3 4 5 6 7 8 9 54 51 56 48 48 53 57 censusIn = 0 0 0 0 0 0 0 0 0 0

Assertion failed.

3   Fail
extras = 99999432; censusIn = getDigitCensus(extras) str = string(censusIn); censusOut = histc(char([str{:}]+string(extras))-48,0:9)+1; assert(isequal(censusIn,censusOut))

test = 0 1 2 3 4 5 6 7 8 9 57 57 57 57 57 52 51 50 censusIn = 0 0 0 0 0 0 0 0 0 0

Assertion failed.

4   Fail
extras = 347879; censusIn = getDigitCensus(extras) str = string(censusIn); censusOut = histc(char([str{:}]+string(extras))-48,0:9)+1; assert(isequal(censusIn,censusOut))

test = 0 1 2 3 4 5 6 7 8 9 51 52 55 56 55 57 censusIn = 0 0 0 0 0 0 0 0 0 0

Assertion failed.

5   Fail
extras = 83870955; censusIn = getDigitCensus(extras) str = string(censusIn); censusOut = histc(char([str{:}]+string(extras))-48,0:9)+1; assert(isequal(censusIn,censusOut))

test = 0 1 2 3 4 5 6 7 8 9 56 51 56 55 48 57 53 53 censusIn = 0 0 0 0 0 0 0 0 0 0

Assertion failed.

6   Fail
extras = 1111111111; censusIn = getDigitCensus(extras) str = string(censusIn); censusOut = histc(char([str{:}]+string(extras))-48,0:9)+1; assert(isequal(censusIn,censusOut))

test = 0 1 2 3 4 5 6 7 8 9 49 49 49 49 49 49 49 49 49 49 censusIn = 0 0 0 0 0 0 0 0 0 0

Assertion failed.

Suggested Problems

More from this Author50

Community Treasure Hunt

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

Start Hunting!