Cody

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

Solution 3160676

Submitted on 11 Oct 2020 by Michael Friesen
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))

xx = 1 dec = 0 xx = 2.0500 dec = 2 xx = 2.0500 dec = 2 xx = 5.0001 dec = 4 xx = 5.0001 dec = 4 xx = 1.0400 dec = 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))

xx = 0.3000 dec = 1 xx = 0.3000 dec = 1 xx = 0.5000 dec = 1 xx = 0.2000 dec = 1 xx = 0.5000 dec = 1 xx = 0.6000 dec = 1 xx = 0.2000 dec = 1 xx = 0.5000 dec = 1 xx = 0.4000 dec = 1 xx = 1 dec = 0 xx = 0.6000 dec = 1 xx = 0.2000 dec = 1 xx = 0.8000 dec = 1 xx = 0.4000 dec = 1 xx = 0.7000 dec = 1 xx = 0.6000 dec = 1 xx = 0.3000 dec = 1 xx = 0.3000 dec = 1 xx = 0.7000 dec = 1 xx = 0.5000 dec = 1 xx = 0.8000 dec = 1 xx = 0.1000 dec = 1 xx = 0.9000 dec = 1 xx = 0.6000 dec = 1 xx = 0.9000 dec = 1 xx = 0.6000 dec = 1 xx = 0.2000 dec = 1 xx = 0.8000 dec = 1 xx = 0.6000 dec = 1 xx = 0.9000 dec = 1 xx = 0.7000 dec = 1 xx = 0.7000 dec = 1 xx = 0.7000 dec = 1 xx = 0.5000 dec = 1 xx = 0.5000 dec = 1 xx = 0.6000 dec = 1 xx = 0.5000 dec = 1 xx = 0 dec = 0 xx = 1 dec = 0 xx = 0.6000 dec = 1 xx = 0.1000 dec = 1 xx = 0.1000 dec = 1 xx = 0.7000 dec = 1 xx = 0.1000 dec = 1 xx = 0.3000 dec = 1 xx = 0.2000 dec = 1 xx = 0.7000 dec = 1 xx = 0.6000 dec = 1 xx = 0.6000 dec = 1 xx = 0.4000 dec = 1 xx = 0.6000 dec = 1 xx = 0.6000 dec = 1 xx = 1 dec = 0 xx = 0.6000 dec = 1 xx = 0.5000 dec = 1 xx = 0.5000 dec = 1 xx = 0.5000 dec = 1 xx = 0.8000 dec = 1 xx = 0.4000 dec = 1 xx = 0.9000 dec = 1 xx = 0.9000 dec = 1 xx = 1 dec = 0 xx = 0.2000 dec = 1 xx = 0 dec = 0 xx = 0.7000 dec = 1 xx = 0.6000 dec = 1 xx = 0.7000 dec = 1 xx = 0.1000 dec = 1 xx = 0.1000 dec = 1 xx = 0.1000 dec = 1 xx = 0.2000 dec = 1 xx = 0.8000 dec = 1 xx = 0.6000 dec = 1 xx = 0.8000 dec = 1 xx = 0.9000 dec = 1 xx = 0.5000 dec = 1 xx = 0 dec = 0 xx = 0.7000 dec = 1 xx = 0.9000 dec = 1 xx = 0.8000 dec = 1 xx = 0.1000 dec = 1 xx = 0.1000 dec = 1 xx = 0.8000 dec = 1 xx = 0.3000 dec = 1 xx = 0.7000 dec = 1 xx = 0.5000 dec = 1 xx = 0.1000 dec = 1 xx = 0.3000 dec = 1 xx = 0.5000 dec = 1 xx = 1 dec = 0 xx = 0.4000 dec = 1 xx = 0.6000 dec = 1 xx = 0.9000 dec = 1 xx = 1 dec = 0 xx = 0.9000 dec = 1 xx = 0.7000 dec = 1 xx = 0.5000 dec = 1 xx = 0.8000 dec = 1 xx = 1 dec = 0 xx = 1 dec = 0 xx = 0.8000 dec = 1 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))

xx = 0.0700 dec = 2 xx = 0.0700 dec = 2 xx = 0.7300 dec = 2 xx = 0.9400 dec = 2 xx = 0.0100 dec = 2 xx = 0.1000 dec = 1 xx = 0.1600 dec = 2 xx = 0.3800 dec = 2 xx = 0.5500 dec = 2 xx = 0.1600 dec = 2 xx = 0.5300 dec = 2 xx = 0.2000 dec = 1 xx = 0.9300 dec = 2 xx = 0.6500 dec = 2 xx = 0.2900 dec = 2 xx = 0.2800 dec = 2 xx = 0.8800 dec = 2 xx = 0.5500 dec = 2 xx = 0.9300 dec = 2 xx = 0.9100 dec = 2 xx = 0.2900 dec = 2 y = 2

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

xx = 1 dec = 0 y = 0

Suggested Problems

Community Treasure Hunt

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

Start Hunting!