Cody

# Problem 43676. Count the Digits in the Box

Solution 2589775

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 2 2 2 2 2 census1 = 1 1 1 1 1 1 1 1 1 1 census1 = 0 0 0 0 0 0 0 0 0 0 census = 0 1 0 0 0 0 0 0 0 0 census = 0 1 6 0 0 0 0 0 0 0 census = 0 1 6 1 0 0 0 0 0 0 census = 0 1 6 1 1 0 0 0 0 0 census = 0 1 6 1 1 1 0 0 0 0 census = 0 1 6 1 1 1 2 0 0 0 census = 0 1 6 1 1 1 2 1 0 0 census = 0 1 6 1 1 1 2 1 1 0 census = 0 1 6 1 1 1 2 1 1 1 census = 2 1 6 1 1 1 2 1 1 1 test = "run" census1 = 2 1 6 1 1 1 2 1 1 1

Error using == Comparison between string and double is not supported. Error in getDigitCensus (line 8) census(n+1) = length(find(census==n)) + length(find(test==n)) Error in Test1 (line 2) censusIn = getDigitCensus(extras)

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 6 3 8 0 0 5 9 census1 = 1 1 1 1 1 1 1 1 1 1 census1 = 0 0 0 0 0 0 0 0 0 0 census = 0 1 0 0 0 0 0 0 0 0 census = 0 1 1 0 0 0 0 0 0 0 census = 0 1 1 2 0 0 0 0 0 0 census = 0 1 1 2 1 0 0 0 0 0 census = 0 1 1 2 1 2 0 0 0 0 census = 0 1 1 2 1 2 2 0 0 0 census = 0 1 1 2 1 2 2 1 0 0 census = 0 1 1 2 1 2 2 1 2 0 census = 0 1 1 2 1 2 2 1 2 2 census = 4 1 1 2 1 2 2 1 2 2 test = "run" census1 = 4 1 1 2 1 2 2 1 2 2

Error using == Comparison between string and double is not supported. Error in getDigitCensus (line 8) census(n+1) = length(find(census==n)) + length(find(test==n)) Error in Test2 (line 2) censusIn = getDigitCensus(extras)

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 9 9 9 9 9 4 3 2 census1 = 1 1 1 1 1 1 1 1 1 1 census1 = 0 0 0 0 0 0 0 0 0 0 census = 0 1 0 0 0 0 0 0 0 0 census = 0 1 2 0 0 0 0 0 0 0 census = 0 1 2 2 0 0 0 0 0 0 census = 0 1 2 2 2 0 0 0 0 0 census = 0 1 2 2 2 1 0 0 0 0 census = 0 1 2 2 2 1 1 0 0 0 census = 0 1 2 2 2 1 1 1 0 0 census = 0 1 2 2 2 1 1 1 1 0 census = 0 1 2 2 2 1 1 1 1 6 census = 2 1 2 2 2 1 1 1 1 6 test = "run" census1 = 2 1 2 2 2 1 1 1 1 6

Error using == Comparison between string and double is not supported. Error in getDigitCensus (line 8) census(n+1) = length(find(census==n)) + length(find(test==n)) Error in Test3 (line 2) censusIn = getDigitCensus(extras)

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 3 4 7 8 7 9 census1 = 1 1 1 1 1 1 1 1 1 1 census1 = 0 0 0 0 0 0 0 0 0 0 census = 0 1 0 0 0 0 0 0 0 0 census = 0 1 1 0 0 0 0 0 0 0 census = 0 1 1 2 0 0 0 0 0 0 census = 0 1 1 2 2 0 0 0 0 0 census = 0 1 1 2 2 1 0 0 0 0 census = 0 1 1 2 2 1 1 0 0 0 census = 0 1 1 2 2 1 1 3 0 0 census = 0 1 1 2 2 1 1 3 2 0 census = 0 1 1 2 2 1 1 3 2 2 census = 2 1 1 2 2 1 1 3 2 2 test = "run" census1 = 2 1 1 2 2 1 1 3 2 2

Error using == Comparison between string and double is not supported. Error in getDigitCensus (line 8) census(n+1) = length(find(census==n)) + length(find(test==n)) Error in Test4 (line 2) censusIn = getDigitCensus(extras)

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 8 3 8 7 0 9 5 5 census1 = 1 1 1 1 1 1 1 1 1 1 census1 = 0 0 0 0 0 0 0 0 0 0 census = 0 1 0 0 0 0 0 0 0 0 census = 0 1 1 0 0 0 0 0 0 0 census = 0 1 1 2 0 0 0 0 0 0 census = 0 1 1 2 1 0 0 0 0 0 census = 0 1 1 2 1 3 0 0 0 0 census = 0 1 1 2 1 3 1 0 0 0 census = 0 1 1 2 1 3 1 2 0 0 census = 0 1 1 2 1 3 1 2 3 0 census = 0 1 1 2 1 3 1 2 3 2 census = 3 1 1 2 1 3 1 2 3 2 test = "run" census1 = 3 1 1 2 1 3 1 2 3 2

Error using == Comparison between string and double is not supported. Error in getDigitCensus (line 8) census(n+1) = length(find(census==n)) + length(find(test==n)) Error in Test5 (line 2) censusIn = getDigitCensus(extras)

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 1 1 1 1 1 1 1 1 1 1 census1 = 1 1 1 1 1 1 1 1 1 1 census1 = 0 0 0 0 0 0 0 0 0 0 census = 0 11 0 0 0 0 0 0 0 0 census = 0 11 1 0 0 0 0 0 0 0 census = 0 11 1 1 0 0 0 0 0 0 census = 0 11 1 1 1 0 0 0 0 0 census = 0 11 1 1 1 1 0 0 0 0 census = 0 11 1 1 1 1 1 0 0 0 census = 0 11 1 1 1 1 1 1 0 0 census = 0 11 1 1 1 1 1 1 1 0 census = 0 11 1 1 1 1 1 1 1 1 census = 2 11 1 1 1 1 1 1 1 1 test = "run" census1 = 2 11 1 1 1 1 1 1 1 1

Error using == Comparison between string and double is not supported. Error in getDigitCensus (line 8) census(n+1) = length(find(census==n)) + length(find(test==n)) Error in Test6 (line 2) censusIn = getDigitCensus(extras)

### Community Treasure Hunt

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

Start Hunting!