Cody

Problem 44785. Lunar Arithmetic (Addition)

Solution 3735938

Submitted on 19 Nov 2020
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))

g = '6' h = '5' lunarResult = 54 lunarResult = 6

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

g = '789' h = '456' lunarResult = 55 56 57 lunarResult = 789

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

g = '12374' h = '00086' lunarResult = 49 50 51 56 54 lunarResult = 12386

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

g = '1652' h = '0029' lunarResult = 49 54 53 57 g = '95412' h = '01652' lunarResult = 57 53 54 53 50 lunarResult = 95652

Assertion failed.

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

g = '1111' h = '0033' lunarResult = 49 49 51 51 g = '4456' h = '1111' lunarResult = 52 52 53 54 g = '0038' h = '4456' lunarResult = 52 52 53 56 lunarResult = 4458

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

g = '04785' h = '85214' lunarResult = 56 53 55 56 53 g = '0001' h = '4785' lunarResult = 52 55 56 53 g = '850615' h = '000001' lunarResult = 56 53 48 54 49 53 g = '14702140' h = '00850615' lunarResult = 49 52 56 53 50 54 52 53 lunarResult = 14852645

Assertion failed.

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

g = '0' h = '9' lunarResult = 57 lunarResult = 9

Suggested Problems

More from this Author72

Community Treasure Hunt

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

Start Hunting!