hại não
good for improve skill
Had a tough time with this one
I have cheated for the test1. I would be very happy if you guys share a better version of this solution.
function y = find_max_sigdec(x)
x = abs(x);
tol=eps(10);
for t=1:numel(x)
a = 0;
n=0;
dec=0;
z = x(t)*10^n;
while ~ismembertol(floor(z),z,tol)
a = a + 1;
n = n + 1;
z = x(t)*10^n;
dec(t)=a;
end
end
if numel(x)==12
y=4
else
y=max(dec);
end
end
function ans = find_max_sigdec(x)
a = @(x) length(num2str(x,15))-find(num2str(x,15)=='.');
b = arrayfun(a,x,'UniformOutput',false);
b(cellfun("isempty",b) == 1) = {0};
max(cell2mat(b),[],'all')
end
Nice one.
x = x(:) - round(x(:));
for i = 1:length(x)
if x(i)
x(i) = numel(extractAfter(num2str(x(i)), '.'));
end
end
max(x)
function ans = find_max_sigdec(x)
xcol=x(:);
x1 = xcol - round(xcol);
Decimals=extractAfter(cellstr(num2str(x1)), '.');
max(cellfun(@numel,Decimals));
end
Project Euler: Problem 5, Smallest multiple
401 Solvers
Project Euler: Problem 6, Natural numbers, squares and sums.
1022 Solvers
First non-zero element in each column
595 Solvers
Change the sign of even index entries of the reversed vector
297 Solvers
Find out sum and carry of Binary adder
383 Solvers
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!