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 106154

Submitted on 4 Jul 2012

Incorrect

122Size
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
Fail
 
%%
X='98765432109876543210987654321098765432109876543210987654321';
Y='98765432109876543210987654321098765432109876543210987654321';
Z='197530864219753086421975308642197530864219753086421975308642';
assert(isequal(dda(X,Y),Z))
Error: Assertion failed.
2
Pass
 
%%
X='6546468768680988454345';
Y='5757557542432424209808098908085353545657657';
Z='5757557542432424209814645376854034534112002';
assert(isequal(dda(X,Y),Z))
sol =
     []
maxX =
    21
sol =
2
maxX =
    20
sol =
20
maxX =
    19
sol =
200
maxX =
    18
sol =
2002
maxX =
    17
sol =
20021
maxX =
    16
sol =
200211
maxX =
    15
sol =
2002114
maxX =
    14
sol =
20021143
maxX =
    13
sol =
200211435
maxX =
    12
sol =
2002114354
maxX =
    11
sol =
20021143543
maxX =
    10
sol =
200211435430
maxX =
     9
sol =
2002114354304
maxX =
     8
sol =
20021143543045
maxX =
     7
sol =
200211435430458
maxX =
     6
sol =
2002114354304586
maxX =
     5
sol =
20021143543045867
maxX =
     4
sol =
200211435430458673
maxX =
     3
sol =
2002114354304586735
maxX =
     2
sol =
20021143543045867354
maxX =
     1
sol =
200211435430458673546
maxX =
     0
sol =
2002114354304586735464
new =
     1
maxX =
    -1
sol =
20021143543045867354641
new =
     8
maxX =
    -2
sol =
200211435430458673546418
new =
     9
maxX =
    -3
sol =
2002114354304586735464189
new =
     0
maxX =
    -4
sol =
20021143543045867354641890
new =
     2
maxX =
    -5
sol =
200211435430458673546418902
new =
     4
maxX =
    -6
sol =
2002114354304586735464189024
new =
     2
maxX =
    -7
sol =
20021143543045867354641890242
new =
     4
maxX =
    -8
sol =
200211435430458673546418902424
new =
     2
maxX =
    -9
sol =
2002114354304586735464189024242
new =
     3
maxX =
   -10
sol =
20021143543045867354641890242423
new =
     4
maxX =
   -11
sol =
200211435430458673546418902424234
new =
     2
maxX =
   -12
sol =
2002114354304586735464189024242342
new =
     4
maxX =
   -13
sol =
20021143543045867354641890242423424
new =
     5
maxX =
   -14
sol =
200211435430458673546418902424234245
new =
     7
maxX =
   -15
sol =
2002114354304586735464189024242342457
new =
     5
maxX =
   -16
sol =
20021143543045867354641890242423424575
new =
     5
maxX =
   -17
sol =
200211435430458673546418902424234245755
new =
     7
maxX =
   -18
sol =
2002114354304586735464189024242342457557
new =
     5
maxX =
   -19
sol =
20021143543045867354641890242423424575575
new =
     7
maxX =
   -20
sol =
200211435430458673546418902424234245755757
new =
     5
maxX =
   -21
sol =
2002114354304586735464189024242342457557575
sol =
5757557542432424209814645376854034534112002
3
Pass
 
%%
X='122';
Y='323';
Z='445';
assert(isequal(dda(X,Y),Z))
sol =
     []
maxX =
     2
sol =
5
maxX =
     1
sol =
54
maxX =
     0
sol =
544
sol =
445
4
Fail
 
%%
X='767678686868667868635435353545';
Y='465464643244242424249787979';
Z='768144151511912111059685141524';
assert(isequal(dda(X,Y),Z))
Error: Assertion failed.