Cody

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

Solution 2791048

Submitted on 5 Aug 2020 by Riccardo Consolo
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))

sn = '0' sn = '0.05' sn = '0.0001' sn = '0.04' sn = '0.33' sn = '0.429' sn = '0.22' sn = '0.1' sn = '0.492' sn = '0.1' sn = '0.31' sn = '0'

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

sn = '0.262' sn = '0.686' sn = '0.464' sn = '0.353' sn = '0.624' sn = '0.347' sn = '0.641' sn = '0.33' sn = '0.576' sn = '0.407' sn = '0.588' sn = '0.765' sn = '0.698' sn = '0.566' sn = '0.646' sn = '0.737' sn = '0.812' sn = '0.171' sn = '0.666' sn = '0.101' sn = '0.871' sn = '0.463' sn = '0.514' sn = '0.599' sn = '0.759' sn = '0.495' sn = '0.959' sn = '0.123' sn = '0.906' sn = '0.593' sn = '0.325' sn = '0.895' sn = '0.318' sn = '0.252' sn = '0.378' sn = '0.11' sn = '0.711' sn = '0.891' sn = '0.705' sn = '0.893' sn = '0.118' sn = '0.442' sn = '0.699' sn = '0.52' sn = '0.266' sn = '0.151' sn = '0.394' sn = '0.579' sn = '0.215' sn = '0.661' sn = '0.986' sn = '0.383' sn = '0.236' sn = '0.23' sn = '0.265' sn = '0.516' sn = '0.222' sn = '0.267' sn = '0.279' sn = '0.092' sn = '0.835' sn = '0.223' sn = '0.889' sn = '0.339' sn = '0.314' sn = '0.848' sn = '0.123' sn = '0.995' sn = '0.382' sn = '0.253' sn = '0.334' sn = '0.283' sn = '0.12' sn = '0.016' sn = '0.388' sn = '0.372' sn = '0.501' sn = '0.531' sn = '0.863' sn = '0.566' sn = '0.619' sn = '0.256' sn = '0.676' sn = '0.819' sn = '0.586' sn = '0.176' sn = '0.98' sn = '0.868' sn = '0.899' sn = '0.12' sn = '0.227' sn = '0.106' sn = '0.135' sn = '0.22' sn = '0.736' sn = '0.464' sn = '0.901' sn = '0.951' sn = '0.425' sn = '0.016'

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

sn = '0.9' sn = '0.01' sn = '0.06' sn = '0.33' sn = '0.35' sn = '0.08' sn = '0.77' sn = '0.42' sn = '0.05' sn = '0.46' sn = '0.79' sn = '0.28' sn = '0.58' sn = '0.57' sn = '0.86' sn = '0.11' sn = '0.43' sn = '0.66' sn = '0.55' sn = '0.12' sn = '0.02' sn = '0.98' sn = '0.24' sn = '0.92' sn = '0.12' sn = '0.5' sn = '0.96' sn = '0.74' sn = '0.31' sn = '0.34' sn = '0.32' sn = '0.18' sn = '0.73' sn = '0.67' sn = '0.85' sn = '0' sn = '0.02' sn = '0.87' sn = '0.97' sn = '0.2' sn = '0.88' sn = '0.83' sn = '0.75' sn = '0.55' sn = '0.99' sn = '0.58' sn = '0.3' sn = '0.24' sn = '0.03' sn = '0.88' sn = '0.25' sn = '0.01' sn = '0.33' sn = '0.39' sn = '0.14' sn = '0.2' sn = '0.76' sn = '0.02' sn = '0.48' sn = '0.77' sn = '0.6' sn = '0.8' sn = '0.98' sn = '0.83' sn = '0.96' sn = '0.45' sn = '0.53' sn = '0.35' sn = '0.81' sn = '0.33' sn = '0.62' sn = '0.36' sn = '0.24' sn = '0.76' sn = '0.71' sn = '0.19' sn = '0.24' sn = '0.55' sn = '0.11' sn = '0.38' sn = '0.73' sn = '0.37' sn = '0.25' sn = '0.51' sn = '0.22' sn = '0.45' sn = '0.91' sn = '0.81' sn = '0.05' sn = '0.41' sn = '0.76' sn = '0.04' sn = '0.43' sn = '0.79' sn = '0.83' sn = '0.02' sn = '0.08' sn = '0' sn = '0.32' sn = '0.87'

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

sn = '0'

Suggested Problems

Community Treasure Hunt

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

Start Hunting!