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 120557

Submitted on 30 Jul 2012 by Khaled Hamed

Correct

144Size
Leading solution size is 22.
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='98765432109876543210987654321098765432109876543210987654321';
Y='98765432109876543210987654321098765432109876543210987654321';
Z='197530864219753086421975308642197530864219753086421975308642';
assert(isequal(dda(X,Y),Z))
a =
  Columns 1 through 10
    18    16    14    12    10     8     6     4     2     0
  Columns 11 through 20
    18    16    14    12    10     8     6     4     2     0
  Columns 21 through 30
    18    16    14    12    10     8     6     4     2     0
  Columns 31 through 40
    18    16    14    12    10     8     6     4     2     0
  Columns 41 through 50
    18    16    14    12    10     8     6     4     2     0
  Columns 51 through 59
    18    16    14    12    10     8     6     4     2
ans =
00197530864219753086421975308642197530864219753086421975308642
2
Pass
 
%%
X='6546468768680988454345';
Y='5757557542432424209808098908085353545657657';
Z='5757557542432424209814645376854034534112002';
assert(isequal(dda(X,Y),Z))
a =
  Columns 1 through 10
     5     7     5     7     5     5     7     5     4     2
  Columns 11 through 20
     4     3     2     4     2     4     2     0     9     8
  Columns 21 through 30
     0    14     5    13    14    13     6    16     7    14
  Columns 31 through 40
    13     9    13     3    14    12    13    10    10    11
  Columns 41 through 43
     9     9    12
ans =
0005757557542432424209814645376854034534112002
3
Pass
 
%%
X='122';
Y='323';
Z='445';
assert(isequal(dda(X,Y),Z))
a =
     4     4     5
ans =
000445
4
Pass
 
%%
X='767678686868667868635435353545';
Y='465464643244242424249787979';
Z='768144151511912111059685141524';
assert(isequal(dda(X,Y),Z))
a =
  Columns 1 through 10
     7     6     7    10    13    13    10    14    10    14
  Columns 11 through 20
    10    11     8    10    11    10    10    10    10     5
  Columns 21 through 30
     9     6     7    14    10    13    10    14    11    14
ans =
000768144151511912111059685141524