Cody

Problem 44762. Find The Difference

Solution 1671157

Submitted on 10 Nov 2018
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 =[ 3 2 2 3 6 9 8 4]; dif_correct =76308633; assert(isequal(difference(x),dif_correct))

min = '2 2 3 3 4 6 8 9' max = '9 8 6 4 3 3 2 2' max = '98643322' min = '22334689' max = 98643322 min = 22334689 ans = 76308633

2   Pass
x =[ 3 2 2 0 0 4]; dif_correct =429966; assert(isequal(difference(x),dif_correct))

min = '0 0 2 2 3 4' max = '4 3 2 2 0 0' max = '432200' min = '002234' max = 432200 min = 2234 ans = 429966

3   Fail
x =[1 1 1]; dif_correct =429966; assert(isequal(difference(x),dif_correct))

min = '1 1 1' max = '1 1 1' max = '111' min = '111' max = 111 min = 111 ans = 0

Assertion failed.

4   Pass
x =[1 2 3 3 2 1]; dif_correct = 219978; assert(isequal(difference(x),dif_correct))

min = '1 1 2 2 3 3' max = '3 3 2 2 1 1' max = '332211' min = '112233' max = 332211 min = 112233 ans = 219978

Community Treasure Hunt

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

Start Hunting!