Cody

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

Solution 1801340

Submitted on 30 Apr 2019 by Beatriz Orozco
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))

xn = 0 0.04 0.22 0.1 0.05 0.33 0.1 0.31 0.0001 0.429 0.492 0 ms = 0 -0.04 -0.22 -0.1 -0.05 -0.33 -0.1 -0.31 -0.0001 -0.429 -0.492 0 yn = -1 y = 0 y = 2 y = 2 y = 2 y = 2 y = 2 y = 2 y = 2 y = 4 y = 4 y = 4 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))

xn = Columns 1 through 14 0.186 0.024 0.235 0.304 0.374 0.327 0.283 0.381 0.362 0.086 0.364 0.297 0.331 0.072 Columns 15 through 28 0.046 0.119 0.099 0.458 0.182 0.115 0.308 0.245 0.064 0.443 0.135 0.019 0.271 0.391 Columns 29 through 42 0.29 0.105 0.13 0.069 0.286 0.062 0.059 0.083 0.062 0.216 0.319 0.496 0.005 0.047 Columns 43 through 56 0.458 0.469 0.327 0.308 0.144 0.486 0.169 0.317 0.093 0.073 0.299 0.189 0.029 0.183 Columns 57 through 70 0.355 0.368 0.144 0.3 0.298 0.405 0.398 0.489 0.107 0.151 0.295 0.223 0.284 0.219 Columns 71 through 84 0.275 0.248 0.076 0.069 0.462 0.485 0.423 0.156 0.415 0.171 0.159 0.018 0.432 0.366 Columns 85 through 98 0.295 0.129 0.395 0.28 0.122 0.427 0.166 0.232 0.126 0.142 0.358 0.431 0.199 0.455 Columns 99 through 100 0.167 0.106 ms = Columns 1 through 14 -0.186 -0.024 -0.235 -0.304 -0.374 -0.327 -0.283 -0.381 -0.362 -0.086 -0.364 -0.297 -0.331 -0.072 Columns 15 through 28 -0.046 -0.119 -0.099 -0.458 -0.182 -0.115 -0.308 -0.245 -0.064 -0.443 -0.135 -0.019 -0.271 -0.391 Columns 29 through 42 -0.29 -0.105 -0.13 -0.069 -0.286 -0.062 -0.059 -0.083 -0.062 -0.216 -0.319 -0.496 -0.005 -0.047 Columns 43 through 56 -0.458 -0.469 -0.327 -0.308 -0.144 -0.486 -0.169 -0.317 -0.093 -0.073 -0.299 -0.189 -0.029 -0.183 Columns 57 through 70 -0.355 -0.368 -0.144 -0.3 -0.298 -0.405 -0.398 -0.489 -0.107 -0.151 -0.295 -0.223 -0.284 -0.219 Columns 71 through 84 -0.275 -0.248 -0.076 -0.069 -0.462 -0.485 -0.423 -0.156 -0.415 -0.171 -0.159 -0.018 -0.432 -0.366 Columns 85 through 98 -0.295 -0.129 -0.395 -0.28 -0.122 -0.427 -0.166 -0.232 -0.126 -0.142 -0.358 -0.431 -0.199 -0.455 Columns 99 through 100 -0.167 -0.106 yn = -1 y = 3 y = 3 y = 3 y = 3 y = 3 y = 3 y = 3 y = 3 y = 3 y = 3 y = 3 y = 3 y = 3 y = 3 y = 3 y = 3 y = 3 y = 3 y = 3 y = 3 y = 3 y = 3 y = 3 y = 3 y = 3 y = 3 y = 3 y = 3 y = 3 y = 3 y = 3 y = 3 y = 3 y = 3 y = 3 y = 3 y = 3 y = 3 y = 3 y = 3 y = 3 y = 3 y = 3 y = 3 y = 3 y = 3 y = 3 y = 3 y = 3 y = 3 y = 3 y = 3 y = 3 y = 3 y = 3 y = 3 y = 3 y = 3 y = 3 y = 3 y = 3 y = 3 y = 3 y = 3 y = 3 y = 3 y = 3 y = 3 y = 3 y = 3 y = 3 y = 3 y = 3 y = 3 y = 3 y = 3 y = 3 y = 3 y = 3 y = 3 y = 3 y = 3 y = 3 y = 3 y = 3 y = 3 y = 3 y = 3 y = 3 y = 3 y = 3 y = 3 y = 3 y = 3 y = 3 y = 3 y = 3 y = 3 y = 3 y = 3

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

xn = Columns 1 through 14 0.42 0.1 0.14 0.08 0.28 0.15 0.3 0.13 0.45 0.32 0.18 0.01 0.12 0.4 0 0.14 0 0.34 0.29 0.03 0.13 0.12 0.09 0.08 0.13 0.4 0.4 0.41 0.43 0.41 0.18 0.33 0.44 0.06 0.25 0.18 0.36 0.37 0.4 0.35 0.37 0.29 0.36 0.48 0.4 0.09 0.26 0.31 0.06 0.43 0.48 0.33 0.41 0.21 0.45 0.44 0.24 0.21 0.33 0.37 0.44 0.32 0.08 0.25 0.48 0.32 0.42 0.13 0.29 0.14 Columns 15 through 20 0.03 0.37 0.17 0.41 0.36 0.37 0.35 0.39 0.14 0.33 0.34 0.07 0.28 0.1 0.18 0.34 0.36 0.21 0.18 0.06 0.49 0.49 0.19 0.21 0.4 0.12 0.25 0.17 0.48 0.42 ms = Columns 1 through 14 -0.42 -0.1 -0.14 -0.08 -0.28 -0.15 -0.3 -0.13 -0.45 -0.32 -0.18 -0.01 -0.12 -0.4 Columns 15 through 28 -0.03 -0.37 -0.17 -0.41 -0.36 -0.37 0 -0.14 0 -0.34 -0.29 -0.03 -0.13 -0.12 Columns 29 through 42 -0.09 -0.08 -0.13 -0.4 -0.4 -0.41 -0.35 -0.39 -0.14 -0.33 -0.34 -0.07 -0.43 -0.41 Columns 43 through 56 -0.18 -0.33 -0.44 -0.06 -0.25 -0.18 -0.36 -0.37 -0.4 -0.35 -0.37 -0.29 -0.28 -0.1 Columns 57 through 70 -0.18 -0.34 -0.36 -0.21 -0.36 -0.48 -0.4 -0.09 -0.26 -0.31 -0.06 -0.43 -0.48 -0.33 Columns 71 through 84 -0.41 -0.21 -0.45 -0.44 -0.18 -0.06 -0.49 -0.49 -0.19 -0.21 -0.24 -0.21 -0.33 -0.37 Columns 85 through 98 -0.44 -0.32 -0.08 -0.25 -0.48 -0.32 -0.42 -0.13 -0.29 -0.14 -0.4 -0.12 -0.25 -0.17 Columns 99 through 100 -0.48 -0.42 yn = -1 y = 2 y = 1 y = 1 y = 2 y = 2 y = 2 y = 2 y = 2 y = 2 y = 2 y = 2 y = 2 y = 2 y = 2 y = 2 y = 2 y = 2 y = 2 y = 2 y = 2 y = 2 y = 2 y = 2 y = 2 y = 2 y = 2 y = 2 y = 2 y = 2 y = 2 y = 2 y = 2 y = 2 y = 2 y = 2 y = 2 y = 2 y = 2 y = 2 y = 2 y = 2 y = 2 y = 2 y = 2 y = 2 y = 2 y = 2 y = 2 y = 2 y = 2 y = 2 y = 2 y = 2 y = 2 y = 2 y = 2 y = 2 y = 2 y = 2 y = 2 y = 2 y = 2 y = 2 y = 2 y = 2 y = 2 y = 2 y = 2 y = 2 y = 2 y = 2 y = 2 y = 2 y = 2 y = 2 y = 2 y = 2 y = 2 y = 2 y = 2 y = 2 y = 2 y = 2 y = 2 y = 2 y = 2 y = 2 y = 2 y = 2 y = 2 y = 2 y = 2 y = 2 y = 2 y = 2 y = 2 y = 2 y = 2 y = 2 y = 2

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

xn = 0 ms = 0 yn = -1 y = 0