Cody

Problem 713. Find the maximum number of decimal places in a set of numbers

Solution 2702385

Submitted on 16 Jul 2020 by Russell Jones
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 = [1.000 1.04 0.22 10.1; 2.05 2.33 4.1 1000.31; 5.00010 6.429 7.492 8.0]; y_correct = 4; assert(isequal(find_max_sigdec(x),y_correct))

n = 0 n = 0 0 n = 0 1 n = 0 2 n = 0 3 n = 0 3 0 n = 0 3 1 n = 0 3 2 n = 0 3 3 n = 0 3 4 n = 0 3 4 0 n = 0 3 4 1 n = 0 3 4 2 y = 4

2   Pass
N = randi(6,1); x1 = rand(1,100); for k = 1:100 x(1,k) = round(x1(1,k)*10^N)/10^N; end assert(isequal(find_max_sigdec(x), N))

n = 0 n = 1 n = 1 0 n = 1 1 n = 1 1 0 n = 1 1 0 0 n = 1 1 0 1 n = 1 1 0 1 0 n = 1 1 0 1 1 n = 1 1 0 1 1 0 n = 1 1 0 1 1 0 0 n = 1 1 0 1 1 0 1 n = 1 1 0 1 1 0 1 0 n = 1 1 0 1 1 0 1 1 n = 1 1 0 1 1 0 1 1 0 n = 1 1 0 1 1 0 1 1 1 n = 1 1 0 1 1 0 1 1 1 0 n = 1 1 0 1 1 0 1 1 1 0 0 n = 1 1 0 1 1 0 1 1 1 0 1 n = 1 1 0 1 1 0 1 1 1 0 1 0 n = 1 1 0 1 1 0 1 1 1 0 1 0 0 n = 1 1 0 1 1 0 1 1 1 0 1 0 1 n = 1 1 0 1 1 0 1 1 1 0 1 0 1 0 n = 1 1 0 1 1 0 1 1 1 0 1 0 1 1 n = 1 1 0 1 1 0 1 1 1 0 1 0 1 1 0 n = 1 1 0 1 1 0 1 1 1 0 1 0 1 1 1 n = 1 1 0 1 1 0 1 1 1 0 1 0 1 1 1 0 n = 1 1 0 1 1 0 1 1 1 0 1 0 1 1 1 1 n = 1 1 0 1 1 0 1 1 1 0 1 0 1 1 1 1 0 n = 1 1 0 1 1 0 1 1 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 0 1 0 1 1 1 1 1 1 0 1 1 1 1 0 1 1 1 1 0 n = 1 1 0 1 1 0 1 1 1 0 1 0 1 1 1 1 1 1 0 1 1 1 1 0 1 1 1 1 1 n = Columns 1 through 29 1 1 0 1 1 0 1 1 1 0 1 0 1 1 1 1 1 1 0 1 1 1 1 0 1 1 1 1 1 Column 30 0 n = Columns 1 through 29 1 1 0 1 1 0 1 1 1 0 1 0 1 1 1 1 1 1 0 1 1 1 1 0 1 1 1 1 1 Columns 30 through 31 0 0 n = Columns 1 through 29 1 1 0 1 1 0 1 1 1 0 1 0 1 1 1 1 1 1 0 1 1 1 1 0 1 1 1 1 1 Columns 30 through 31 0 1 n = Columns 1 through 29 1 1 0 1 1 0 1 1 1 0 1 0 1 1 1 1 1 1 0 1 1 1 1 0 1 1 1 1 1 Columns 30 through 32 0 1 0 n = Columns 1 through 29 1 1 0 1 1 0 1 1 1 0 1 0 1 1 1 1 1 1 0 1 1 1 1 0 1 1 1 1 1 Columns 30 through 32 0 1 1 n = Columns 1 through 29 1 1 0 1 1 0 1 1 1 0 1 0 1 1 1 1 1 1 0 1 1 1 1 0 1 1 1 1 1 Columns 30 through 33 0 1 1 0 n = Columns 1 through 29 1 1 0 1 1 0 1 1 1 0 1 0 1 1 1 1 1 1 0 1 1 1 1 0 1 1 1 1 1 Columns 30 through 33 0 1 1 1 n = Columns 1 through 29 1 1 0 1 1 0 1 1 1 0 1 0 1 1 1 1 1 1 0 1 1 1 1 0 1 1 1 1 1 Columns 30 through 34 0 1 1 1 0 n = Columns 1 through 29 1 1 0 1 1 0 1 1 1 0 1 0 1 1 1 1 1 1 0 1 1 1 1 0 1 1 1 1 1 Columns 30 through 34 0 1 1 1 1 n = Columns 1 through 29 1 1 0 1 1 0 1 1 1 0 1 0 1 1 1 1 1 1 0 1 1 1 1 0 1 1 1 1 1 Columns 30 through 35 0 1 1 1 1 0 n = Columns 1 through 29 1 1 0 1 1 0 1 1 1 0 1 0 1 1 1 1 1 1 0 1 1 1 1 0 1 1 1 1 1 Columns 30 through 35 0 1 1 1 1 1 n = Columns 1 through 29 1 1 0 1 1 0 1 1 1 0 1 0 1 1 1 1 1 1 0 1 1 1 1 0 1 1 1 1 1 Columns 30 through 36 0 1 1 1 1 1 0 n = Columns 1 through 29 1 1 0 1 1 0 1 1 1 0 1 0 1 1 1 1 1 1 0 1 1 1 1 0 1 1 1 1 1 Columns 30 through 36 0 1 1 1 1 1 1 n = Columns 1 through 29 1 1 0 1 1 0 1 1 1 0 1 0 1 1 1 1 1 1 0 1 1 1 1 0 1 1 1 1 1 Columns 30 through 37 0 1 1 1 1 1 1 0 n = Columns 1 through 29 1 1 0 1 1 0 1 1 1 0 1 0 1 1 1 1 1 1 0 1 1 1 1 0 1 1 1 1 1 Columns 30 through 37 0 1 1 1 1 1 1 1 n = Columns 1 through 29 1 1 0 1 1 0 1 1 1 0 1 0 1 1 1 1 1 1 0 1 1 1 1 0 1 1 1 1 1 Columns 30 through 38 0 1 1 1 1 1 1 1 0 n = Columns 1 through 29 1 1 0 1 1 0 1 1 1 0 1 0 1 1 1 1 1 1 0 1 1 1 1 0 1 1 1 1 1 Columns 30 through 38 0 1 1 1 1 1 1 1 1 n = Columns 1 through 29 1 1 0 1 1 0 1 1 1 0 1 0 1 1 1 1 1 1 0 1 1 1 1 0 1 1 1 1 1 Columns 30 through 39 0 1 1 1 1 1 1 1 1 0 n = Columns 1 through 29 ...

3   Pass
N = randi(6,1); a = rand(5,20); for k = 1:20 for m = 1:5 x(m,k) = round(a(m,k)*10^N)/10^N; end end assert(isequal(find_max_sigdec(x), N))

n = 0 n = 1 n = 2 n = 3 n = 3 0 n = 3 1 n = 3 2 n = 3 3 n = 3 3 0 n = 3 3 1 n = 3 3 2 n = 3 3 3 n = 3 3 3 0 n = 3 3 3 1 n = 3 3 3 2 n = 3 3 3 2 0 n = 3 3 3 2 1 n = 3 3 3 2 2 n = 3 3 3 2 3 n = 3 3 3 2 3 0 n = 3 3 3 2 3 1 n = 3 3 3 2 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3 3 3 2 3 3 3 1 3 3 3 3 3 3 3 3 0 n = 3 3 3 2 3 3 3 1 3 3 3 3 3 3 3 3 1 n = 3 3 3 2 3 3 3 1 3 3 3 3 3 3 3 3 2 n = 3 3 3 2 3 3 3 1 3 3 3 3 3 3 3 3 3 n = 3 3 3 2 3 3 3 1 3 3 3 3 3 3 3 3 3 0 n = 3 3 3 2 3 3 3 1 3 3 3 3 3 3 3 3 3 1 n = 3 3 3 2 3 3 3 1 3 3 3 3 3 3 3 3 3 2 n = 3 3 3 2 3 3 3 1 3 3 3 3 3 3 3 3 3 3 n = 3 3 3 2 3 3 3 1 3 3 3 3 3 3 3 3 3 3 0 n = 3 3 3 2 3 3 3 1 3 3 3 3 3 3 3 3 3 3 1 n = 3 3 3 2 3 3 3 1 3 3 3 3 3 3 3 3 3 3 2 n = 3 3 3 2 3 3 3 1 3 3 3 3 3 3 3 3 3 3 3 n = 3 3 3 2 3 3 3 1 3 3 3 3 3 3 3 3 3 3 3 0 n = 3 3 3 2 3 3 3 1 3 3 3 3 3 3 3 3 3 3 3 1 n = 3 3 3 2 3 3 3 1 3 3 3 3 3 3 3 3 3 3 3 2 n = 3 3 3 2 3 3 3 1 3 3 3 3 3 3 3 3 3 3 3 3 y = 3

4   Pass
x = 1; assert(isequal(find_max_sigdec(x), 0))

n = 0 y = 0

Suggested Problems

Community Treasure Hunt

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

Start Hunting!