Cody

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

Solution 1753370

Submitted on 17 Mar 2019 by Maryam Majidi
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))

y = [] c = 0 c = '0' c = -1 y = -1 c = 0.0500 c = '0.05' c = 2 y = -1 2 c = 1.0000e-04 c = '0.0001' c = 4 y = -1 2 4 c = 0.0400 c = '0.04' c = 2 y = -1 2 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))

y = [] c = 0.9400 c = '0.94' c = 2 y = 2 c = 0.3700 c = '0.37' c = 2 y = 2 2 c = 0.1200 c = '0.12' c = 2 y = 2 2 2 c = 0.2200 c = '0.22' c = 2 y = 2 2 2 2 c = 0.9700 c = '0.97' c = 2 y = 2 2 2 2 2 c = 0 c = '0' c = -1 y = 2 2 2 2 2 -1 c = 0.1000 c = '0.1' c = 1 y = 2 2 2 2 2 -1 1 c = 0.1900 c = '0.19' c = 2 y = 2 2 2 2 2 -1 1 2 c = 0.4500 c = '0.45' c = 2 y = 2 2 2 2 2 -1 1 2 2 c = 0.6000 c = '0.6' c = 1 y = 2 2 2 2 2 -1 1 2 2 1 c = 0.3000 c = '0.3' c = 1 y = 2 2 2 2 2 -1 1 2 2 1 1 c = 0.4300 c = '0.43' c = 2 y = 2 2 2 2 2 -1 1 2 2 1 1 2 c = 0.1200 c = '0.12' c = 2 y = 2 2 2 2 2 -1 1 2 2 1 1 2 2 c = 0.8800 c = '0.88' c = 2 y = 2 2 2 2 2 -1 1 2 2 1 1 2 2 2 c = 0.2900 c = '0.29' c = 2 y = 2 2 2 2 2 -1 1 2 2 1 1 2 2 2 2 c = 0.4800 c = '0.48' c = 2 y = 2 2 2 2 2 -1 1 2 2 1 1 2 2 2 2 2 c = 0.6400 c = '0.64' c = 2 y = 2 2 2 2 2 -1 1 2 2 1 1 2 2 2 2 2 2 c = 0.2900 c = '0.29' c = 2 y = 2 2 2 2 2 -1 1 2 2 1 1 2 2 2 2 2 2 2 c = 0.0300 c = '0.03' c = 2 y = 2 2 2 2 2 -1 1 2 2 1 1 2 2 2 2 2 2 2 2 c = 0.5200 c = '0.52' c = 2 y = 2 2 2 2 2 -1 1 2 2 1 1 2 2 2 2 2 2 2 2 2 c = 0.7100 c = '0.71' c = 2 y = 2 2 2 2 2 -1 1 2 2 1 1 2 2 2 2 2 2 2 2 2 2 c = 0.8700 c = '0.87' c = 2 y = 2 2 2 2 2 -1 1 2 2 1 1 2 2 2 2 2 2 2 2 2 2 2 c = 0.5800 c = '0.58' c = 2 y = 2 2 2 2 2 -1 1 2 2 1 1 2 2 2 2 2 2 2 2 2 2 2 2 c = 0.6600 c = '0.66' c = 2 y = 2 2 2 2 2 -1 1 2 2 1 1 2 2 2 2 2 2 2 2 2 2 2 2 2 c = 0.3100 c = '0.31' c = 2 y = 2 2 2 2 2 -1 1 2 2 1 1 2 2 2 2 2 2 2 2 2 2 2 2 2 2 c = 0.0300 c = '0.03' c = 2 y = 2 2 2 2 2 -1 1 2 2 1 1 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 c = 0.0900 c = '0.09' c = 2 y = 2 2 2 2 2 -1 1 2 2 1 1 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 c = 0 c = '0' c = -1 y = 2 2 2 2 2 -1 1 2 2 1 1 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 -1 c = 0.0100 c = '0.01' c = 2 y = 2 2 2 2 2 -1 1 2 2 1 1 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 -1 2 c = 0.3000 c = '0.3' c = 1 y = Columns 1 through 29 2 2 2 2 2 -1 1 2 2 1 1 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 -1 2 Column 30 1 c = 0.0300 c = '0.03' c = 2 y = Columns 1 through 29 2 2 2 2 2 -1 1 2 2 1 1 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 -1 2 Columns 30 through 31 1 2 c = 0.9100 c = '0.91' c = 2 y = Columns 1 through 29 2 2 2 2 2 -1 1 2 2 1 1 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 -1 2 Columns 30 through 32 1 2 2 c = 0.6100 c = '0.61' c = 2 y = Columns 1 through 29 2 2 2 2 2 -1 1 2 2 1 1 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 -1 2 Columns 30 through 33 1 2 2 2 c = 0.8700 c = '0.87' c = 2 y = Columns 1 through 29 2 2 2 2 2 -1 1 2 2 1 1 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 -1 2 Columns 30 through 34 1 2 2 2 2 c = 0.1100 c = '0.11' c = 2 y = Columns 1 through 29 2 2 2 2 2 -1 1 2 2 1 1 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 -1 2 Columns 30 through 35 1 2 2 2 2 2 c = 0.8500 c = '0.85' c = 2 y = Columns 1 through 29 2 2 2 2 2 -1 1 2 2 1 1 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 -1 2 Columns 30 through 36 1 2 2 2 2 2 2 c = 0.6800 c = '0.68' c = 2 y = Columns 1 through 29 2 2 2 2 2 -1 1 2 2 1 1 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 -1 2 Columns 30 through 37 1 2 2 2 2 2 2 2 c = 0.4000 c = '0.4' c = 1 y = Columns 1 through 29 2 2 2 2 2 -1 1 2 2 1 1 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 -1 2 Columns 30 through 38 1 2 2 2 2 2 2 2 1 c = 0.6100 c = '0.61' c = 2 y = Columns 1 through 29 2 2 2 2 2 -1 1 2 2 1 1 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 -1 2 Columns 30 through 39 1 2 2 2 2 2 2 2 1 2 c = 0.9600 c = '0.96' c = 2 y = Columns 1 through 29 2 2 2 2 2 -1 1 2 2 1 1 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 -1 2 Columns 30 through 40 1 2 2 2 2 2 2 2 1 2 2 c = 0.7300 c = '0.73' c = 2 y = Columns 1 through 29 2 2 2 2 2 -1 1 2 2 1 1 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 -1 2 Columns 30 through 41 1 2 2 2 2 2 2 2 1 2 2 2 c = 0.0100 c = '0.01' c = 2 y = Columns 1 through 29 2 2 2 2 2 -1 1 2 2 1 1 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 -1 2 Columns 30 through 42 1 2 2 2 2 2 2 2 1 2 2 2 2 c = 0.6300 c = '0.63' c = 2 y = Columns 1 through 29 2 2 2 2 2 -1 1 2 2 1 1 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 -1 2 Columns 30 through 43 1 2 2 2 2 2 2 2 1 2 2 2 2 2 c = 0.3400 c = '0.34' c = 2 y = Columns 1 through 29 2 2 2 2 2 -1 1 2 2 1 1 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 -1 2 Columns 30 through 44 1 2 2 2 2 2 2 2 1 2 2 2 2 2 2 c = 0.4600 c = '0.46' c = 2 y = Columns 1 through 29 2 2 2 2 2 -1 1 2 2 1 1 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 -1 2 Columns 30 through 45 1 2 2 2 2 2 2 2 1 2 2 2 2 2 2 2 c = 0.2300 c = '0.23' c = 2 y = Columns 1 through 29 2 2 2 2 2 -1 1 2 2 1 1 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 -1 2 Columns 30 through 46 1 2 2 2 2 2 2 2 1 2 2 2 2 2 2 2 ...

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))

y = [] c = 0.8800 c = '0.88' c = 2 y = 2 c = 0.6000 c = '0.6' c = 1 y = 2 1 c = 0.0800 c = '0.08' c = 2 y = 2 1 2 c = 0.8700 c = '0.87' c = 2 y = 2 1 2 2 c = 0.0200 c = '0.02' c = 2 y = 2 1 2 2 2 c = 0.7000 c = '0.7' c = 1 y = 2 1 2 2 2 1 c = 0 c = '0' c = -1 y = 2 1 2 2 2 1 -1 c = 0.5500 c = '0.55' c = 2 y = 2 1 2 2 2 1 -1 2 c = 0.3600 c = '0.36' c = 2 y = 2 1 2 2 2 1 -1 2 2 c = 0.1200 c = '0.12' c = 2 y = 2 1 2 2 2 1 -1 2 2 2 c = 0.3800 c = '0.38' c = 2 y = 2 1 2 2 2 1 -1 2 2 2 2 c = 0.4200 c = '0.42' c = 2 y = 2 1 2 2 2 1 -1 2 2 2 2 2 c = 0.7400 c = '0.74' c = 2 y = 2 1 2 2 2 1 -1 2 2 2 2 2 2 c = 0.8000 c = '0.8' c = 1 y = 2 1 2 2 2 1 -1 2 2 2 2 2 2 1 c = 0.4900 c = '0.49' c = 2 y = 2 1 2 2 2 1 -1 2 2 2 2 2 2 1 2 c = 0.6300 c = '0.63' c = 2 y = 2 1 2 2 2 1 -1 2 2 2 2 2 2 1 2 2 c = 0.8600 c = '0.86' c = 2 y = 2 1 2 2 2 1 -1 2 2 2 2 2 2 1 2 2 2 c = 0.2800 c = '0.28' c = 2 y = 2 1 2 2 2 1 -1 2 2 2 2 2 2 1 2 2 2 2 c = 0.3000 c = '0.3' c = 1 y = 2 1 2 2 2 1 -1 2 2 2 2 2 2 1 2 2 2 2 1 c = 0.4100 c = '0.41' c = 2 y = 2 1 2 2 2 1 -1 2 2 2 2 2 2 1 2 2 2 2 1 2 y = 2

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

y = 0