Cody

Solution 228774

Submitted on 9 Apr 2013 by VIVI
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
%% a = [1 2 3 4]; t = 0; b_correct = [4 3 2 1]; assert(isequal(targetSort(a,t),b_correct))

z = 1 2 3 4 z = 2 1 3 4 z = 3 1 2 4 z = 3 2 1 4 z = 4 2 1 3 z = 4 3 1 2 z = 4 3 2 1

2   Pass
%% a = -4:10; t = 3.6; b_correct = [-4 -3 10 -2 9 -1 8 0 7 1 6 2 5 3 4]; assert(isequal(targetSort(a,t),b_correct))

z = -4 -3 -2 -1 0 1 2 3 4 5 6 7 8 9 10 z = -3 -4 -2 -1 0 1 2 3 4 5 6 7 8 9 10 z = -2 -4 -3 -1 0 1 2 3 4 5 6 7 8 9 10 z = -1 -4 -3 -2 0 1 2 3 4 5 6 7 8 9 10 z = 0 -4 -3 -2 -1 1 2 3 4 5 6 7 8 9 10 z = 1 -4 -3 -2 -1 0 2 3 4 5 6 7 8 9 10 z = 2 -4 -3 -2 -1 0 1 3 4 5 6 7 8 9 10 z = 3 -4 -3 -2 -1 0 1 2 4 5 6 7 8 9 10 z = 4 -4 -3 -2 -1 0 1 2 3 5 6 7 8 9 10 z = -4 4 -3 -2 -1 0 1 2 3 5 6 7 8 9 10 z = -4 -3 4 -2 -1 0 1 2 3 5 6 7 8 9 10 z = -4 -3 -2 4 -1 0 1 2 3 5 6 7 8 9 10 z = -4 -3 -2 -1 4 0 1 2 3 5 6 7 8 9 10 z = -4 -3 -2 -1 0 4 1 2 3 5 6 7 8 9 10 z = -4 -3 -2 -1 0 1 4 2 3 5 6 7 8 9 10 z = -4 -3 -2 -1 0 1 2 4 3 5 6 7 8 9 10 z = -4 -3 -2 -1 0 1 2 3 4 5 6 7 8 9 10 z = -4 -3 -2 -1 0 1 2 5 4 3 6 7 8 9 10 z = -4 -3 -2 -1 0 1 2 5 3 4 6 7 8 9 10 z = -4 -3 -2 -1 0 1 6 5 3 4 2 7 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-2 -1 8 0 7 1 6 2 5 3 4 9 z = -4 -3 10 -2 9 8 0 7 1 6 2 5 3 4 -1 z = -4 -3 10 -2 9 -1 0 7 1 6 2 5 3 4 8 z = -4 -3 10 -2 9 -1 8 7 1 6 2 5 3 4 0 z = -4 -3 10 -2 9 -1 8 0 1 6 2 5 3 4 7 z = -4 -3 10 -2 9 -1 8 0 7 6 2 5 3 4 1 z = -4 -3 10 -2 9 -1 8 0 7 1 2 5 3 4 6 z = -4 -3 10 -2 9 -1 8 0 7 1 6 5 3 4 2 z = -4 -3 10 -2 9 -1 8 0 7 1 6 2 3 4 5 z = -4 -3 10 -2 9 -1 8 0 7 1 6 2 5 4 3 z = -4 -3 10 -2 9 -1 8 0 7 1 6 2 5 3 4

3   Pass
%% a = 12; t = pi; b_correct = 12; assert(isequal(targetSort(a,t),b_correct))

z = 12

4   Pass
%% a = -100:-95; t = 100; b_correct = [-100 -99 -98 -97 -96 -95]; assert(isequal(targetSort(a,t),b_correct))

z = -100 -99 -98 -97 -96 -95 z = -99 -100 -98 -97 -96 -95 z = -98 -100 -99 -97 -96 -95 z = -97 -100 -99 -98 -96 -95 z = -96 -100 -99 -98 -97 -95 z = -95 -100 -99 -98 -97 -96 z = -100 -95 -99 -98 -97 -96 z = -100 -99 -95 -98 -97 -96 z = -100 -99 -98 -95 -97 -96 z = -100 -99 -98 -97 -95 -96 z = -100 -99 -98 -97 -96 -95