Cody

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

Solution 2764300

Submitted on 31 Jul 2020 by Alexander
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))

x = 1.0e+03 * 0.0010 0.0020 0.0050 0.0010 0.0023 0.0064 0.0002 0.0041 0.0075 0.0101 1.0003 0.0080 ind = 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))

x = 0.3000 0.6000 0.5000 0.8000 0.2000 0.5000 0.5000 1.0000 0.2000 0.4000 0.3000 0.8000 0.6000 0.2000 0.7000 0.5000 0 1.0000 0.4000 0.4000 0.4000 0.1000 0.7000 0.2000 0.4000 0.1000 0.9000 0.3000 0.1000 0.8000 0.1000 0.8000 0.9000 0.3000 0.9000 0.5000 0.3000 0.3000 0 0.6000 0.4000 0.1000 0.2000 0.8000 0.1000 0.9000 0.6000 0.3000 0.7000 0.4000 1.0000 0.6000 0.2000 0.6000 0.2000 0.5000 0.7000 1.0000 0.2000 0.5000 0.4000 0.6000 0.4000 0.1000 0.6000 0.5000 0.4000 0.1000 0.4000 0 0.1000 0.7000 0.7000 0.1000 0.3000 0.9000 0 0.7000 0.7000 0.6000 1.0000 0.1000 0.3000 0.9000 0.6000 0.2000 0.3000 0.2000 0.3000 0.1000 0.4000 0.3000 0.9000 0.8000 0.5000 0.4000 0.7000 1.0000 0.7000 0.9000 ind = 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))

x = 0.0300 0.0300 0.3100 0.7200 0.4000 0.5700 1.0000 0.3900 0.4100 0.5800 0.5800 0.1800 0.2600 0.4300 0.7300 0.1000 0.9600 0.5400 0.0600 0.1000 0.3400 0.1400 0.4200 0.3900 0.2700 0.0200 0.2500 0.7400 0.8500 0.0500 0.6600 0.5100 0.6700 0.7300 0.6900 0.2100 0.1800 0.1500 0.5900 0.5100 0.0300 0.7800 0.0100 0.9100 0.4500 0.2300 0.3100 0.7500 0.8100 0.7500 0.5600 0.5600 0.0500 0.3000 0.6100 0.3900 0.8200 0.6900 0.1500 0.2400 0.8900 0.8100 0.9700 0.2400 0.6400 0.8700 0.7400 0.2100 0.6700 0.0300 0.1900 0.3600 0.0200 0.9800 0.1600 0.7100 0.9600 0.3200 0.0100 0.6600 0.6000 0.7500 0.5100 0.7100 0.4400 0.6200 0.7900 0.1400 0.8900 0.3400 0.9100 0.9500 0.0400 0.2900 0.2800 0.1900 0.4300 0.8500 0.8300 0.6700 ind = 2

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

x = 1 ind = 0

Suggested Problems

Community Treasure Hunt

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

Start Hunting!