Discover MakerZone

MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi

Learn more

Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.

Apply Today

Solution 293965

Submitted on 1 Aug 2013 by @bmtran

Correct

42Size
Leading solution size is 11.
This solution is locked. To view this solution, you need to provide a solution of the same size or smaller.

Test Suite

Test
Code Input and Output
1
Pass
 
%%
x = [1];
y = [1];
assert(isequal(individualNumSum(x),y))

                    
2
Pass
 
%%
x = [103];
y = [4];
assert(isequal(individualNumSum(x),y))
y =
     4
3
Pass
 
%%
x=[189 22 39 88 55 485 769 215 3685 4589];
y = [9 4 3 7 1 8 4 8 4 8];
assert(isequal(individualNumSum(x),y))
y =
    18
y =
     9
y =
     9     4
y =
     9     4    12
y =
     9     4     3
y =
     9     4     3    16
y =
     9     4     3     7
y =
     9     4     3     7    10
y =
     9     4     3     7     1
y =
     9     4     3     7     1    17
y =
     9     4     3     7     1     8
y =
     9     4     3     7     1     8    22
y =
     9     4     3     7     1     8     4
y =
     9     4     3     7     1     8     4     8
y =
     9     4     3     7     1     8     4     8    22
y =
     9     4     3     7     1     8     4     8     4
y =
     9     4     3     7     1     8     4     8     4    26
y =
     9     4     3     7     1     8     4     8     4     8
4
Pass
 
%%
x=[1111 2222 3333 4444 5555 6666 7777 8888 9999 0];
y = [4 8 3 7 2 6 1 5 9 0];
assert(isequal(individualNumSum(x),y))
y =
     4
y =
     4     8
y =
     4     8    12
y =
     4     8     3
y =
     4     8     3    16
y =
     4     8     3     7
y =
     4     8     3     7    20
y =
     4     8     3     7     2
y =
     4     8     3     7     2    24
y =
     4     8     3     7     2     6
y =
     4     8     3     7     2     6    28
y =
     4     8     3     7     2     6    10
y =
     4     8     3     7     2     6     1
y =
     4     8     3     7     2     6     1    32
y =
     4     8     3     7     2     6     1     5
y =
     4     8     3     7     2     6     1     5    36
y =
     4     8     3     7     2     6     1     5     9
5
Pass
 
%%
x=[111 222 333 444 555 666 777 888 999 0];
y = [3 6 9 3 6 9 3 6 9 0];
assert(isequal(individualNumSum(x),y))
y =
     3
y =
     3     6
y =
     3     6     9
y =
     3     6     9    12
y =
     3     6     9     3
y =
     3     6     9     3    15
y =
     3     6     9     3     6
y =
     3     6     9     3     6    18
y =
     3     6     9     3     6     9
y =
     3     6     9     3     6     9    21
y =
     3     6     9     3     6     9     3
y =
     3     6     9     3     6     9     3    24
y =
     3     6     9     3     6     9     3     6
y =
     3     6     9     3     6     9     3     6    27
y =
     3     6     9     3     6     9     3     6     9
6
Pass
 
%%
x=[11 3];
y = [2 3];
assert(isequal(individualNumSum(x),y))
y =
     2