How does this work?
This is precomputation, lookup table. Quite common method, when input variable is from small set(and computation long and hard). Now I think it is cheating in this competition, sorry:]
Test | Status | Code Input and Output |
---|---|---|
1 | Pass |
%%
a = 1;
b = 2;
out = sumDigits(a);
assert(isequal(out, b))
|
2 | Pass |
%%
a = 10;
b = 7;
out = sumDigits(a);
assert(isequal(out, b))
|
3 | Pass |
%%
a = 16;
b = 25;
out = sumDigits(a);
assert(isequal(out, b))
|
338 Solvers
We love vectorized solutions. Problem 1 : remove the row average.
547 Solvers
3072 Solvers
521 Solvers
616 Solvers
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!