Cody

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

Solution 1944671

Submitted on 21 Sep 2019 by Vu Thanh Nam
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))

b = 0 0.0500 0.0001 0.0400 0.3300 0.4290 0.2200 0.1000 0.4920 0.1000 0.3100 0 c = 13×6 char array ' 0' ' 0.05' '0.0001' ' 0.04' ' 0.33' ' 0.429' ' 0.22' ' 0.1' ' 0.492' ' 0.1' ' 0.31' ' 0' ' 10' 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))

b = 0.8000 0.1000 0.6000 0.9000 0.9000 0.3000 0.6000 0.7000 0.4000 0.5000 0.1000 0.8000 0.1000 0.3000 0.6000 0.2000 0.9000 0.8000 0.4000 0.6000 0.9000 0.8000 0.4000 0.4000 0.4000 0.1000 0.8000 0.2000 0.5000 0.7000 0.7000 0.5000 0.7000 0.1000 0.3000 0.1000 0.7000 0.6000 0.5000 0.8000 0.5000 0.6000 0.9000 0.7000 0.7000 0.9000 0.1000 0.9000 0.3000 0.5000 0 0.4000 0.2000 0.5000 0.8000 0.4000 0.5000 0.4000 0.1000 0.4000 0.5000 0.6000 0.7000 0.7000 0.8000 0 0.2000 0.6000 0.3000 0.5000 0.7000 0.9000 0.8000 0.7000 0 0.8000 0.8000 0.2000 0.5000 0.7000 0.4000 0.2000 0.1000 0.9000 0.5000 0.7000 0.2000 0 0.6000 0.6000 0.2000 0.1000 0.6000 0.9000 0.3000 0.2000 0 0.7000 0.4000 0.5000 c = 101×3 char array '0.8' '0.1' '0.6' '0.9' '0.9' '0.3' '0.6' '0.7' '0.4' '0.5' '0.1' '0.8' '0.1' '0.3' '0.6' '0.2' '0.9' '0.8' '0.4' '0.6' '0.9' '0.8' '0.4' '0.4' '0.4' '0.1' '0.8' '0.2' '0.5' '0.7' '0.7' '0.5' '0.7' '0.1' '0.3' '0.1' '0.7' '0.6' '0.5' '0.8' '0.5' '0.6' '0.9' '0.7' '0.7' '0.9' '0.1' '0.9' '0.3' '0.5' ' 0' '0.4' '0.2' '0.5' '0.8' '0.4' '0.5' '0.4' '0.1' '0.4' '0.5' '0.6' '0.7' '0.7' '0.8' ' 0' '0.2' '0.6' '0.3' '0.5' '0.7' '0.9' '0.8' '0.7' ' 0' '0.8' '0.8' '0.2' '0.5' '0.7' '0.4' '0.2' '0.1' '0.9' '0.5' '0.7' '0.2' ' 0' '0.6' '0.6' '0.2' '0.1' '0.6' '0.9' '0.3' '0.2' ' 0' '0.7' '0.4' '0.5' ' 10' y = 1

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

b = 0.6800 0.0200 0.2300 0.2500 0.3900 0.6000 0.2500 0.3400 0.5400 0.7300 0.0700 0.8800 0.6700 0.1700 0.9800 0.8800 0.6700 0.9100 0.8600 0.0200 0.7600 0.6400 0.1300 0.6400 0.3200 0.7600 0.1700 0.4300 0.6600 0.9800 0.4400 0.4200 0.4700 0.5600 0.4900 0.8300 0.0200 0.7100 0.0300 0.0900 0.8800 0.9500 0.1800 0.8800 0.2500 0.6200 0.0700 0.1100 0.3200 0.1400 0.9000 0.9200 0.0100 0.9600 0.0300 0.7700 0.7000 0.5700 0.8200 0.5800 0.0200 0.9400 0.1900 0.2200 0.4400 0.6400 0.2800 0.4400 0.9700 0.0500 0.8200 0.3800 0.6200 0.1100 0.9300 0.8400 0.4300 0.5200 0.0900 0.4100 0.0200 0.1200 0.7700 0.9800 0.1500 0.1000 0.8800 0.8000 0.9200 0.7400 0.6500 0.6600 0.9900 0.2700 0.7500 0.2600 0.9600 0.6700 0.3100 0.0700 c = 101×4 char array '0.68' '0.02' '0.23' '0.25' '0.39' ' 0.6' '0.25' '0.34' '0.54' '0.73' '0.07' '0.88' '0.67' '0.17' '0.98' '0.88' '0.67' '0.91' '0.86' '0.02' '0.76' '0.64' '0.13' '0.64' '0.32' '0.76' '0.17' '0.43' '0.66' '0.98' '0.44' '0.42' '0.47' '0.56' '0.49' '0.83' '0.02' '0.71' '0.03' '0.09' '0.88' '0.95' '0.18' '0.88' '0.25' '0.62' '0.07' '0.11' '0.32' '0.14' ' 0.9' '0.92' '0.01' '0.96' '0.03' '0.77' ' 0.7' '0.57' '0.82' '0.58' '0.02' '0.94' '0.19' '0.22' '0.44' '0.64' '0.28' '0.44' '0.97' '0.05' '0.82' '0.38' '0.62' '0.11' '0.93' '0.84' '0.43' '0.52' '0.09' '0.41' '0.02' '0.12' '0.77' '0.98' '0.15' ' 0.1' '0.88' ' 0.8' '0.92' '0.74' '0.65' '0.66' '0.99' '0.27' '0.75' '0.26' '0.96' '0.67' '0.31' '0.07' ' 10' y = 2

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

b = 0 c = 2×2 char array ' 0' '10' y = 0

### Community Treasure Hunt

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

Start Hunting!