Cody

# Problem 563. How to add?

Solution 429852

Submitted on 10 Apr 2014 by Jan Orwat
This solution is locked. To view this solution, you need to provide a solution of the same size or smaller.

### Test Suite

Test Status Code Input and Output
1   Pass
%% X='98765432109876543210987654321098765432109876543210987654321'; Y='98765432109876543210987654321098765432109876543210987654321'; Z='197530864219753086421975308642197530864219753086421975308642'; assert(isequal(dda(X,Y),Z))

z = Columns 1 through 16 2 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Columns 17 through 32 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Columns 33 through 48 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Columns 49 through 60 0 0 0 0 0 0 0 0 0 0 0 0 z = Columns 1 through 16 2 4 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Columns 17 through 32 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Columns 33 through 48 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Columns 49 through 60 0 0 0 0 0 0 0 0 0 0 0 0 z = Columns 1 through 16 2 4 6 0 0 0 0 0 0 0 0 0 0 0 0 0 Columns 17 through 32 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Columns 33 through 48 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Columns 49 through 60 0 0 0 0 0 0 0 0 0 0 0 0 z = Columns 1 through 16 2 4 6 8 0 0 0 0 0 0 0 0 0 0 0 0 Columns 17 through 32 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Columns 33 through 48 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Columns 49 through 60 0 0 0 0 0 0 0 0 0 0 0 0 z = Columns 1 through 16 2 4 6 8 10 0 0 0 0 0 0 0 0 0 0 0 Columns 17 through 32 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Columns 33 through 48 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Columns 49 through 60 0 0 0 0 0 0 0 0 0 0 0 0 z = Columns 1 through 16 2 4 6 8 10 13 0 0 0 0 0 0 0 0 0 0 Columns 17 through 32 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Columns 33 through 48 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Columns 49 through 60 0 0 0 0 0 0 0 0 0 0 0 0 z = Columns 1 through 16 2 4 6 8 10 13 15 0 0 0 0 0 0 0 0 0 Columns 17 through 32 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Columns 33 through 48 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Columns 49 through 60 0 0 0 0 0 0 0 0 0 0 0 0 z = Columns 1 through 16 2 4 6 8 10 13 15 17 0 0 0 0 0 0 0 0 Columns 17 through 32 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Columns 33 through 48 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Columns 49 through 60 0 0 0 0 0 0 0 0 0 0 0 0 z = Columns 1 through 16 2 4 6 8 10 13 15 17 19 0 0 0 0 0 0 0 Columns 17 through 32 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Columns 33 through 48 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Columns 49 through 60 0 0 0 0 0 0 0 0 0 0 0 0 z = Columns 1 through 16 2 4 6 8 10 13 15 17 19 1 0 0 0 0 0 0 Columns 17 through 32 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Columns 33 through 48 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Columns 49 through 60 0 0 0 0 0 0 0 0 0 0 0 0 z = Columns 1 through 16 2 4 6 8 10 13 15 17 19 1 2 0 0 0 0 0 Columns 17 through 32 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Columns 33 through 48 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Columns 49 through 60 0 0 0 0 0 0 0 0 0 0 0 0 z = Columns 1 through 16 2 4 6 8 10 13 15 17 19 1 2 4 0 0 0 0 Columns 17 through 32 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Columns 33 through 48 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Columns 49 through 60 0 0 0 0 0 0 0 0 0 0 0 0 z = Columns 1 through 16 2 4 6 8 10 13 15 17 19 1 2 4 6 0 0 0 Columns 17 through 32 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Columns 33 through 48 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Columns 49 through 60 0 0 0 0 0 0 0 0 0 0 0 0 z = Columns 1 through 16 2 4 6 8 10 13 15 17 19 1 2 4 6 8 0 0 Columns 17 through 32 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Columns 33 through 48 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Columns 49 through 60 0 0 0 0 0 0 0 0 0 0 0 0 z = Columns 1 through 16 2 4 6 8 10 13 15 17 19 1 2 4 6 8 10 0 Columns 17 through 32 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Columns 33 through 48 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Columns 49 through 60 0 0 0 0 0 0 0 0 0 0 0 0 z = Columns 1 through 16 2 4 6 8 10 13 15 17 19 1 2 4 6 8 10 13 Columns 17 through 32 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Columns 33 through 48 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Columns 49 through 60 0 0 0 0 0 0 0 0 0 0 0 0 z = Columns 1 through 16 2 4 6 8 10 13 15 17 19 1 2 4 6 8 10 13 Columns 17 through 32 15 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Columns 33 through 48 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Columns 49 through 60 0 0 0 0 0 0 0 0 0 0 0 0 z = Columns 1 through 16 2 4 6 8 10 13 15 17 19 1 2 4 6 8 10 13 Columns 17 through 32 15 17 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Columns 33 through 48 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Columns 49 through 60 0 0 0 0 0 0 0 0 0 0 0 0 z = Columns 1 through 16 2 4 6 8 10 13 15 17 19 1 2 4 6 8 10 13 Columns 17 through 32 15 17 19 0 0 0 0 0 0 0 0 0 0 0 0 0 Columns 33 through 48 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Columns 49 through 60 0 0 0 0 0 0 0 0 0 0 0 0 z = Columns 1 through 16 2 4 6 8 10 13 15 17 19 1 2 4 6 8 10 13 Columns 17 through 32 15 17 19 1 0 0 0 0 0 0 0 0 0 0 0 0 Columns 33 through 48 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Columns 49 through 60 0 0 0 0 0 0 0 0 0 0 0 0 z = Columns 1 through 16 2 4 6 8 10 13 15 17 19 1 2 4 6 8 10 13 Columns 17 through 32 15 17 19 1 2 0 0 0 0 0 0 0 0 0 0 0 Columns 33 through 48 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Columns 49 through 60 0 0 0 0 0 0 0 0 0 0 0 0 z = Columns 1 through 16 2 4 6 8 10 13 15 17 19 1 2 4 6 8 10 13 Columns 17 through 32 15 17 19 1 2 4 0 0 0 0 0 0 0 0 0 0 Columns 33 through 48 0 ...

2   Pass
%% X='6546468768680988454345'; Y='5757557542432424209808098908085353545657657'; Z='5757557542432424209814645376854034534112002'; assert(isequal(dda(X,Y),Z))

z = Columns 1 through 16 12 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Columns 17 through 32 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Columns 33 through 44 0 0 0 0 0 0 0 0 0 0 0 0 z = Columns 1 through 16 12 10 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Columns 17 through 32 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Columns 33 through 44 0 0 0 0 0 0 0 0 0 0 0 0 z = Columns 1 through 16 12 10 10 0 0 0 0 0 0 0 0 0 0 0 0 0 Columns 17 through 32 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Columns 33 through 44 0 0 0 0 0 0 0 0 0 0 0 0 z = Columns 1 through 16 12 10 10 12 0 0 0 0 0 0 0 0 0 0 0 0 Columns 17 through 32 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Columns 33 through 44 0 0 0 0 0 0 0 0 0 0 0 0 z = Columns 1 through 16 12 10 10 12 11 0 0 0 0 0 0 0 0 0 0 0 Columns 17 through 32 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Columns 33 through 44 0 0 0 0 0 0 0 0 0 0 0 0 z = Columns 1 through 16 12 10 10 12 11 11 0 0 0 0 0 0 0 0 0 0 Columns 17 through 32 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Columns 33 through 44 0 0 0 0 0 0 0 0 0 0 0 0 z = Columns 1 through 16 12 10 10 12 11 11 14 0 0 0 0 0 0 0 0 0 Columns 17 through 32 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Columns 33 through 44 0 0 0 0 0 0 0 0 0 0 0 0 z = Columns 1 through 16 12 10 10 12 11 11 14 13 0 0 0 0 0 0 0 0 Columns 17 through 32 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Columns 33 through 44 0 0 0 0 0 0 0 0 0 0 0 0 z = Columns 1 through 16 12 10 10 12 11 11 14 13 15 0 0 0 0 0 0 0 Columns 17 through 32 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Columns 33 through 44 0 0 0 0 0 0 0 0 0 0 0 0 z = Columns 1 through 16 12 10 10 12 11 11 14 13 15 4 0 0 0 0 0 0 Columns 17 through 32 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Columns 33 through 44 0 0 0 0 0 0 0 0 0 0 0 0 z = Columns 1 through 16 12 10 10 12 11 11 14 13 15 4 13 0 0 0 0 0 Columns 17 through 32 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Columns 33 through 44 0 0 0 0 0 0 0 0 0 0 0 0 z = Columns 1 through 16 12 10 10 12 11 11 14 13 15 4 13 10 0 0 0 0 Columns 17 through 32 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Columns 33 through 44 0 0 0 0 0 0 0 0 0 0 0 0 z = Columns 1 through 16 12 10 10 12 11 11 14 13 15 4 13 10 14 0 0 0 Columns 17 through 32 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Columns 33 through 44 0 0 0 0 0 0 0 0 0 0 0 0 z = Columns 1 through 16 12 10 10 12 11 11 14 13 15 4 13 10 14 15 0 0 Columns 17 through 32 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Columns 33 through 44 0 0 0 0 0 0 0 0 0 0 0 0 z = Columns 1 through 16 12 10 10 12 11 11 14 13 15 4 13 10 14 15 8 0 Columns 17 through 32 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Columns 33 through 44 0 0 0 0 0 0 0 0 0 0 0 0 z = Columns 1 through 16 12 10 10 12 11 11 14 13 15 4 13 10 14 15 8 16 Columns 17 through 32 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Columns 33 through 44 0 0 0 0 0 0 0 0 0 0 0 0 z = Columns 1 through 16 12 10 10 12 11 11 14 13 15 4 13 10 14 15 8 16 Columns 17 through 32 7 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Columns 33 through 44 0 0 0 0 0 0 0 0 0 0 0 0 z = Columns 1 through 16 12 10 10 12 11 11 14 13 15 4 13 10 14 15 8 16 Columns 17 through 32 7 13 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Columns 33 through 44 0 0 0 0 0 0 0 0 0 0 0 0 z = Columns 1 through 16 12 10 10 12 11 11 14 13 15 4 13 10 14 15 8 16 Columns 17 through 32 7 13 15 0 0 0 0 0 0 0 0 0 0 0 0 0 Columns 33 through 44 0 0 0 0 0 0 0 0 0 0 0 0 z = Columns 1 through 16 12 10 10 12 11 11 14 13 15 4 13 10 14 15 8 16 Columns 17 through 32 7 13 15 14 0 0 0 0 0 0 0 0 0 0 0 0 Columns 33 through 44 0 0 0 0 0 0 0 0 0 0 0 0 z = Columns 1 through 16 12 10 10 12 11 11 14 13 15 4 13 10 14 15 8 16 Columns 17 through 32 7 13 15 14 6 0 0 0 0 0 0 0 0 0 0 0 Columns 33 through 44 0 0 0 0 0 0 0 0 0 0 0 0 z = Columns 1 through 16 12 10 10 12 11 11 14 13 15 4 13 10 14 15 8 16 Columns 17 through 32 7 13 15 14 6 14 0 0 0 0 0 0 0 0 0 0 Columns 33 through 44 0 0 0 0 0 0 0 0 0 0 0 0 z = Columns 1 through 16 12 10 10 12 11 11 14 13 15 4 13 10 14 15 8 16 Columns 17 through 32 7 13 15 14 6 14 1 0 0 0 0 0 0 0 0 0 Columns 33 through 44 0 0 0 0 0 0 0 0 0 0 0 0 z = Columns 1 through 16 12 10 10 12 11 11 14 13 15 4 13 10 14 15 8 16 Columns 17 through 32 7 13 15 14 6 14 1 8 0 0 0 0 0 0 0 0 Columns 33 through 44 0 0 0 0 0 0 0 0 0 0 0 0 z = Columns 1 through 16 12 10 10 12 11 11 14 13 15 4 13 10 14 15 8 16 Columns 17 through 32 7 13 15 14 6 14 1 8 9 0 0 0 0 0 0 0 Columns 33 through 44 0 0 0 0 0 0 0 0 0 0 0 0 z = Columns 1 through 16 12 10 10 12 11 11 14 13 15 4 13 10 14 15 8 16 Columns 17 through 32 7 13 15 14 6 14 1 8 9 0 0 0 0 0 0 0 Columns 33 through 44 0 0 0 0 0 0 0 0 0 0 0 0 z = Columns 1 through 16 12 10 10 12 11 11 14 13 15 4 13 10 14 15 8 16 Columns 17 through 32 7 13 15 14 6 14 1 8 9 0 2 0 0 0 0 0 Columns 33 through 44 0 0 0 0 0 0 0 0 0 0 0 0 z = Columns 1 through 16 12 10 10 12 11 11 14 13 15 4 13 10 14 15 8 16 Columns 17 through 32 7 13 15 14 6 14 1 8 9 0 2 4 0 0 0 0 Columns 33 through 44 0 0 0 0 0 0 0 0 0 0 0 0 z = Columns 1 through 16 12 10 10 12 11 11 14 13 15 4 13 10 14 15 8 16 Columns 17 through 32 7 13 15 14 6 14 1 8 9 0 2 4 2 0 0 0 Columns 33 through 44 0 0 0 0 0 0 0 0 0 0 0 0 z = Columns 1 through 16 12 10 10 12 11 11 14 13 15...

3   Pass
%% X='122'; Y='323'; Z='445'; assert(isequal(dda(X,Y),Z))

z = 5 0 0 0 z = 5 4 0 0 z = 5 4 4 0 z = 5 4 4 0

4   Pass
%% X='767678686868667868635435353545'; Y='465464643244242424249787979'; Z='768144151511912111059685141524'; assert(isequal(dda(X,Y),Z))

z = Columns 1 through 16 14 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Columns 17 through 31 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 z = Columns 1 through 16 14 12 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Columns 17 through 31 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 z = Columns 1 through 16 14 12 15 0 0 0 0 0 0 0 0 0 0 0 0 0 Columns 17 through 31 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 z = Columns 1 through 16 14 12 15 11 0 0 0 0 0 0 0 0 0 0 0 0 Columns 17 through 31 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 z = Columns 1 through 16 14 12 15 11 14 0 0 0 0 0 0 0 0 0 0 0 Columns 17 through 31 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 z = Columns 1 through 16 14 12 15 11 14 11 0 0 0 0 0 0 0 0 0 0 Columns 17 through 31 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 z = Columns 1 through 16 14 12 15 11 14 11 15 0 0 0 0 0 0 0 0 0 Columns 17 through 31 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 z = Columns 1 through 16 14 12 15 11 14 11 15 8 0 0 0 0 0 0 0 0 Columns 17 through 31 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 z = Columns 1 through 16 14 12 15 11 14 11 15 8 6 0 0 0 0 0 0 0 Columns 17 through 31 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 z = Columns 1 through 16 14 12 15 11 14 11 15 8 6 9 0 0 0 0 0 0 Columns 17 through 31 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 z = Columns 1 through 16 14 12 15 11 14 11 15 8 6 9 5 0 0 0 0 0 Columns 17 through 31 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 z = Columns 1 through 16 14 12 15 11 14 11 15 8 6 9 5 10 0 0 0 0 Columns 17 through 31 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 z = Columns 1 through 16 14 12 15 11 14 11 15 8 6 9 5 10 11 0 0 0 Columns 17 through 31 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 z = Columns 1 through 16 14 12 15 11 14 11 15 8 6 9 5 10 11 11 0 0 Columns 17 through 31 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 z = Columns 1 through 16 14 12 15 11 14 11 15 8 6 9 5 10 11 11 11 0 Columns 17 through 31 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 z = Columns 1 through 16 14 12 15 11 14 11 15 8 6 9 5 10 11 11 11 12 Columns 17 through 31 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 z = Columns 1 through 16 14 12 15 11 14 11 15 8 6 9 5 10 11 11 11 12 Columns 17 through 31 11 0 0 0 0 0 0 0 0 0 0 0 0 0 0 z = Columns 1 through 16 14 12 15 11 14 11 15 8 6 9 5 10 11 11 11 12 Columns 17 through 31 11 9 0 0 0 0 0 0 0 0 0 0 0 0 0 z = Columns 1 through 16 14 12 15 11 14 11 15 8 6 9 5 10 11 11 11 12 Columns 17 through 31 11 9 11 0 0 0 0 0 0 0 0 0 0 0 0 z = Columns 1 through 16 14 12 15 11 14 11 15 8 6 9 5 10 11 11 11 12 Columns 17 through 31 11 9 11 11 0 0 0 0 0 0 0 0 0 0 0 z = Columns 1 through 16 14 12 15 11 14 11 15 8 6 9 5 10 11 11 11 12 Columns 17 through 31 11 9 11 11 15 0 0 0 0 0 0 0 0 0 0 z = Columns 1 through 16 14 12 15 11 14 11 15 8 6 9 5 10 11 11 11 12 Columns 17 through 31 11 9 11 11 15 11 0 0 0 0 0 0 0 0 0 z = Columns 1 through 16 14 12 15 11 14 11 15 8 6 9 5 10 11 11 11 12 Columns 17 through 31 11 9 11 11 15 11 15 0 0 0 0 0 0 0 0 z = Columns 1 through 16 14 12 15 11 14 11 15 8 6 9 5 10 11 11 11 12 Columns 17 through 31 11 9 11 11 15 11 15 11 0 0 0 0 0 0 0 z = Columns 1 through 16 14 12 15 11 14 11 15 8 6 9 5 10 11 11 11 12 Columns 17 through 31 11 9 11 11 15 11 15 11 14 0 0 0 0 0 0 z = Columns 1 through 16 14 12 15 11 14 11 15 8 6 9 5 10 11 11 11 12 Columns 17 through 31 11 9 11 11 15 11 15 11 14 14 0 0 0 0 0 z = Columns 1 through 16 14 12 15 11 14 11 15 8 6 9 5 10 11 11 11 12 Columns 17 through 31 11 9 11 11 15 11 15 11 14 14 11 0 0 0 0 z = Columns 1 through 16 14 12 15 11 14 11 15 8 6 9 5 10 11 11 11 12 Columns 17 through 31 11 9 11 11 15 11 15 11 14 14 11 8 0 0 0 z = Columns 1 through 16 14 12 15 11 14 11 15 8 6 9 5 10 11 11 11 12 Columns 17 through 31 11 9 11 11 15 11 15 11 14 14 11 8 6 0 0 z = Columns 1 through 16 14 12 15 11 14 11 15 8 6 9 5 10 11 11 11 12 Columns 17 through 31 11 9 11 11 15 11 15 11 14 14 11 8 6 7 0 z = Columns 1 through 16 14 12 15 11 14 11 15 8 6 9 5 10 11 11 11 12 Columns 17 through 31 11 9 11 11 15 11 15 11 14 14 11 8 6 7 0