Cody

Problem 44785. Lunar Arithmetic (Addition)

Solution 2761870

Submitted on 31 Jul 2020 by Venkatesh Rachabathuni
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 = 5; y = 6; assert(isequal(lunarAddition(x,y),6))

Rem = 5 0 Rem = 5 6 s = 0 0 0 6 lunarResult = 6

2   Pass
x = 456; y = 789; assert(isequal(lunarAddition(x,y),789))

Rem = 6 0 Rem = 6 9 s = 0 0 0 9 Rem = 5 0 Rem = 5 8 s = 0 0 0 0 9 8 Rem = 4 0 Rem = 4 7 s = 0 0 0 0 0 9 8 7 lunarResult = 7 lunarResult = 78 lunarResult = 789

3   Pass
x = 86; y = 12374; assert(isequal(lunarAddition(x,y),12386))

Rem = 6 0 Rem = 6 4 s = 0 0 0 6 Rem = 8 0 Rem = 8 7 s = 0 0 0 0 6 8 Rem = 0 0 Rem = 0 3 s = 0 0 0 0 0 6 8 3 Rem = 0 0 Rem = 0 2 s = 0 0 0 0 0 0 6 8 3 2 Rem = 0 0 Rem = 0 1 s = 0 0 0 0 0 0 0 6 8 3 2 1 lunarResult = 1 lunarResult = 12 lunarResult = 123 lunarResult = 1238 lunarResult = 12386

4   Pass
x = 29; y = 1652; z = 95412; assert(isequal(lunarAddition(x,y,z),95659))

Rem = 9 0 0 Rem = 9 2 0 Rem = 9 2 2 s = 0 0 0 0 0 9 Rem = 2 0 0 Rem = 2 5 0 Rem = 2 5 1 s = 0 0 0 0 0 0 0 9 5 Rem = 0 0 0 Rem = 0 6 0 Rem = 0 6 4 s = 0 0 0 0 0 0 0 0 0 9 5 6 Rem = 0 0 0 Rem = 0 1 0 Rem = 0 1 5 s = 0 0 0 0 0 0 0 0 0 0 0 9 5 6 5 Rem = 0 0 0 Rem = 0 0 0 Rem = 0 0 9 s = 0 0 0 0 0 0 0 0 0 0 0 0 0 9 5 6 5 9 lunarResult = 9 lunarResult = 95 lunarResult = 956 lunarResult = 9565 lunarResult = 95659

5   Pass
x = 33; y = 1111; z = 4456; a = 38; assert(isequal(lunarAddition(x,y,z,a),4458))

Rem = 3 0 0 0 Rem = 3 1 0 0 Rem = 3 1 6 0 Rem = 3 1 6 8 s = 0 0 0 0 0 0 0 8 Rem = 3 0 0 0 Rem = 3 1 0 0 Rem = 3 1 5 0 Rem = 3 1 5 3 s = 0 0 0 0 0 0 0 0 0 0 8 5 Rem = 0 0 0 0 Rem = 0 1 0 0 Rem = 0 1 4 0 Rem = 0 1 4 0 s = 0 0 0 0 0 0 0 0 0 0 0 0 0 8 5 4 Rem = 0 0 0 0 Rem = 0 1 0 0 Rem = 0 1 4 0 Rem = 0 1 4 0 s = 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 8 5 4 4 lunarResult = 4 lunarResult = 44 lunarResult = 445 lunarResult = 4458

6   Pass
x = 85214; y = 4785; z = 1; a = 850615; b = 14702140; assert(isequal(lunarAddition(x,y,z,a,b),14885785))

Rem = 4 0 0 0 0 Rem = 4 5 0 0 0 Rem = 4 5 1 0 0 Rem = 4 5 1 5 0 Rem = 4 5 1 5 0 s = 0 0 0 0 0 0 0 0 0 5 Rem = 1 0 0 0 0 Rem = 1 8 0 0 0 Rem = 1 8 0 0 0 Rem = 1 8 0 1 0 Rem = 1 8 0 1 4 s = 0 0 0 0 0 0 0 0 0 0 0 0 0 5 8 Rem = 2 0 0 0 0 Rem = 2 7 0 0 0 Rem = 2 7 0 0 0 Rem = 2 7 0 6 0 Rem = 2 7 0 6 1 s = 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 5 8 7 Rem = 5 0 0 0 0 Rem = 5 4 0 0 0 Rem = 5 4 0 0 0 Rem = 5 4 0 0 0 Rem = 5 4 0 0 2 s = 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 5 8 7 5 Rem = 8 0 0 0 0 Rem = 8 0 0 0 0 Rem = 8 0 0 0 0 Rem = 8 0 0 5 0 Rem = 8 0 0 5 0 s = 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 5 8 7 5 8 Rem = 0 0 0 0 0 Rem = 0 0 0 0 0 Rem = 0 0 0 0 0 Rem = 0 0 0 8 0 Rem = 0 0 0 8 7 s = 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 5 8 7 5 8 8 Rem = 0 0 0 0 0 Rem = 0 0 0 0 0 Rem = 0 0 0 0 0 Rem = 0 0 0 0 0 Rem = 0 0 0 0 4 s = 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 5 8 7 5 8 8 4 Rem = 0 0 0 0 0 Rem = 0 0 0 0 0 Rem = 0 0 0 0 0 Rem = 0 0 0 0 0 Rem = 0 0 0 0 1 s = 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 5 8 7 5 8 8 4 1 lunarResult = 1 lunarResult = 14 lunarResult = 148 lunarResult = 1488 lunarResult = 14885 lunarResult = 148857 lunarResult = 1488578 lunarResult = 14885785

7   Pass
x = 9; y = 0; assert(isequal(lunarAddition(x,y),9))

Rem = 9 0 Rem = 9 0 s = 0 0 0 9 lunarResult = 9

Suggested Problems

More from this Author62

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!