Cody

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

Solution 91815

Submitted on 24 May 2012 by Aurelien Queffurust
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))

C = '1' '1.04' '0.22' '10.1' '2.05' '2.33' '4.1' '1000.31' '5.0001' '6.429' '7.492' '8' maxis = 0 maxis = 0 maxis = 2 maxis = 4 maxis = 4 maxis = 4 maxis = 4 maxis = 4 maxis = 4 maxis = 4 maxis = 4 maxis = 4 maxis = 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))

C = Columns 1 through 5 '0.939' '0.876' '0.55' '0.622' '0.587' Columns 6 through 10 '0.208' '0.301' '0.471' '0.23' '0.844' Columns 11 through 15 '0.195' '0.226' '0.171' '0.228' '0.436' Columns 16 through 20 '0.311' '0.923' '0.43' '0.185' '0.905' Columns 21 through 25 '0.98' '0.439' '0.111' '0.258' '0.409' Columns 26 through 30 '0.595' '0.262' '0.603' '0.711' '0.222' Columns 31 through 35 '0.117' '0.297' '0.319' '0.424' '0.508' Columns 36 through 40 '0.086' '0.262' '0.801' '0.029' '0.929' Columns 41 through 45 '0.73' '0.489' '0.579' '0.237' '0.459' Columns 46 through 50 '0.963' '0.547' '0.521' '0.232' '0.489' Columns 51 through 55 '0.624' '0.679' '0.396' '0.367' '0.988' Columns 56 through 60 '0.038' '0.885' '0.913' '0.796' '0.099' Columns 61 through 65 '0.262' '0.335' '0.68' '0.137' '0.721' Columns 66 through 70 '0.107' '0.654' '0.494' '0.779' '0.715' Columns 71 through 75 '0.904' '0.891' '0.334' '0.699' '0.198' Columns 76 through 80 '0.031' '0.744' '0.5' '0.48' '0.905' Columns 81 through 85 '0.61' '0.618' '0.859' '0.805' '0.577' Columns 86 through 90 '0.183' '0.24' '0.887' '0.029' '0.49' Columns 91 through 95 '0.168' '0.979' '0.713' '0.5' '0.471' Columns 96 through 100 '0.06' '0.682' '0.042' '0.071' '0.522' maxis = 0 maxis = 3 maxis = 3 maxis = 3 maxis = 3 maxis = 3 maxis = 3 maxis = 3 maxis = 3 maxis = 3 maxis = 3 maxis = 3 maxis = 3 maxis = 3 maxis = 3 maxis = 3 maxis = 3 maxis = 3 maxis = 3 maxis = 3 maxis = 3 maxis = 3 maxis = 3 maxis = 3 maxis = 3 maxis = 3 maxis = 3 maxis = 3 maxis = 3 maxis = 3 maxis = 3 maxis = 3 maxis = 3 maxis = 3 maxis = 3 maxis = 3 maxis = 3 maxis = 3 maxis = 3 maxis = 3 maxis = 3 maxis = 3 maxis = 3 maxis = 3 maxis = 3 maxis = 3 maxis = 3 maxis = 3 maxis = 3 maxis = 3 maxis = 3 maxis = 3 maxis = 3 maxis = 3 maxis = 3 maxis = 3 maxis = 3 maxis = 3 maxis = 3 maxis = 3 maxis = 3 maxis = 3 maxis = 3 maxis = 3 maxis = 3 maxis = 3 maxis = 3 maxis = 3 maxis = 3 maxis = 3 maxis = 3 maxis = 3 maxis = 3 maxis = 3 maxis = 3 maxis = 3 maxis = 3 maxis = 3 maxis = 3 maxis = 3 maxis = 3 maxis = 3 maxis = 3 maxis = 3 maxis = 3 maxis = 3 maxis = 3 maxis = 3 maxis = 3 maxis = 3 maxis = 3 maxis = 3 maxis = 3 maxis = 3 maxis = 3 maxis = 3 maxis = 3 maxis = 3 maxis = 3 maxis = 3 maxis = 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))

C = Columns 1 through 6 '0.8' '0.5' '0.4' '0.4' '0.5' '0.4' '0.8' '1' '0.8' '0.8' '0.4' '0' '0.7' '0.6' '0.1' '0.8' '0.7' '1' '0.1' '0.8' '0.1' '0.1' '0.6' '0.2' '0.7' '0.5' '0.2' '0.4' '0.3' '0.1' Columns 7 through 12 '0.4' '0.9' '0.5' '0.7' '0.2' '0.6' '0.2' '0.1' '0.9' '0.7' '0.1' '0.9' '0.5' '0.7' '0.4' '0.5' '1' '0.7' '0.3' '0.3' '1' '0.7' '0.2' '0.2' '1' '0.4' '0.3' '0.7' '0' '0.4' Columns 13 through 18 '0.5' '0.4' '0.6' '0.3' '0.7' '0.9' '1' '0.2' '0.2' '0.6' '0.3' '0.8' '0.2' '0.4' '0.4' '0.3' '0.6' '0.3' '0.9' '0.5' '0.6' '0.8' '0.1' '0.6' '0.6' '0.1' '0.3' '1' '0.9' '0' Columns 19 through 20 '0.4' '0.1' '0.3' '0.6' '0.2' '0.5' '0.2' '0.7' '0.4' '0.7' maxis = 0 maxis = 1 maxis = 1 maxis = 1 maxis = 1 maxis = 1 maxis = 1 maxis = 1 maxis = 1 maxis = 1 maxis = 1 maxis = 1 maxis = 1 maxis = 1 maxis = 1 maxis = 1 maxis = 1 maxis = 1 maxis = 1 maxis = 1 maxis = 1 maxis = 1 maxis = 1 maxis = 1 maxis = 1 maxis = 1 maxis = 1 maxis = 1 maxis = 1 maxis = 1 maxis = 1 maxis = 1 maxis = 1 maxis = 1 maxis = 1 maxis = 1 maxis = 1 maxis = 1 maxis = 1 maxis = 1 maxis = 1 maxis = 1 maxis = 1 maxis = 1 maxis = 1 maxis = 1 maxis = 1 maxis = 1 maxis = 1 maxis = 1 maxis = 1 maxis = 1 maxis = 1 maxis = 1 maxis = 1 maxis = 1 maxis = 1 maxis = 1 maxis = 1 maxis = 1 maxis = 1 maxis = 1 maxis = 1 maxis = 1 maxis = 1 maxis = 1 maxis = 1 maxis = 1 maxis = 1 maxis = 1 maxis = 1 maxis = 1 maxis = 1 maxis = 1 maxis = 1 maxis = 1 maxis = 1 maxis = 1 maxis = 1 maxis = 1 maxis = 1 maxis = 1 maxis = 1 maxis = 1 maxis = 1 maxis = 1 maxis = 1 maxis = 1 maxis = 1 maxis = 1 maxis = 1 maxis = 1 maxis = 1 maxis = 1 maxis = 1 maxis = 1 maxis = 1 maxis = 1 maxis = 1 maxis = 1 maxis = 1

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

C = '1' maxis = 0 maxis = 0