Cody

Solution 896470

Submitted on 27 May 2016 by Dennis Winston
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))

row = 1 col = 4 A = 1 2 3 4 m = 4 i = 4 A = 1 2 3 0 m = 3 i = 4 3 A = 1 2 0 0 m = 2 i = 4 3 2 A = 1 0 0 0 m = 1 i = 4 3 2 1 A = 0 0 0 0 b = 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))

row = 1 col = 15 A = Columns 1 through 9 7.6000 6.6000 5.6000 4.6000 3.6000 2.6000 1.6000 0.6000 0.4000 Columns 10 through 15 1.4000 2.4000 3.4000 4.4000 5.4000 6.4000 m = 7.6000 i = 1 A = Columns 1 through 9 0 6.6000 5.6000 4.6000 3.6000 2.6000 1.6000 0.6000 0.4000 Columns 10 through 15 1.4000 2.4000 3.4000 4.4000 5.4000 6.4000 m = 6.6000 i = 1 2 A = Columns 1 through 9 0 0 5.6000 4.6000 3.6000 2.6000 1.6000 0.6000 0.4000 Columns 10 through 15 1.4000 2.4000 3.4000 4.4000 5.4000 6.4000 m = 6.4000 i = 1 2 15 A = Columns 1 through 9 0 0 5.6000 4.6000 3.6000 2.6000 1.6000 0.6000 0.4000 Columns 10 through 15 1.4000 2.4000 3.4000 4.4000 5.4000 0 m = 5.6000 i = 1 2 15 3 A = Columns 1 through 9 0 0 0 4.6000 3.6000 2.6000 1.6000 0.6000 0.4000 Columns 10 through 15 1.4000 2.4000 3.4000 4.4000 5.4000 0 m = 5.4000 i = 1 2 15 3 14 A = Columns 1 through 9 0 0 0 4.6000 3.6000 2.6000 1.6000 0.6000 0.4000 Columns 10 through 15 1.4000 2.4000 3.4000 4.4000 0 0 m = 4.6000 i = 1 2 15 3 14 4 A = Columns 1 through 9 0 0 0 0 3.6000 2.6000 1.6000 0.6000 0.4000 Columns 10 through 15 1.4000 2.4000 3.4000 4.4000 0 0 m = 4.4000 i = 1 2 15 3 14 4 13 A = Columns 1 through 9 0 0 0 0 3.6000 2.6000 1.6000 0.6000 0.4000 Columns 10 through 15 1.4000 2.4000 3.4000 0 0 0 m = 3.6000 i = 1 2 15 3 14 4 13 5 A = Columns 1 through 9 0 0 0 0 0 2.6000 1.6000 0.6000 0.4000 Columns 10 through 15 1.4000 2.4000 3.4000 0 0 0 m = 3.4000 i = 1 2 15 3 14 4 13 5 12 A = Columns 1 through 9 0 0 0 0 0 2.6000 1.6000 0.6000 0.4000 Columns 10 through 15 1.4000 2.4000 0 0 0 0 m = 2.6000 i = 1 2 15 3 14 4 13 5 12 6 A = Columns 1 through 9 0 0 0 0 0 0 1.6000 0.6000 0.4000 Columns 10 through 15 1.4000 2.4000 0 0 0 0 m = 2.4000 i = 1 2 15 3 14 4 13 5 12 6 11 A = Columns 1 through 9 0 0 0 0 0 0 1.6000 0.6000 0.4000 Columns 10 through 15 1.4000 0 0 0 0 0 m = 1.6000 i = 1 2 15 3 14 4 13 5 12 6 11 7 A = Columns 1 through 9 0 0 0 0 0 0 0 0.6000 0.4000 Columns 10 through 15 1.4000 0 0 0 0 0 m = 1.4000 i = 1 2 15 3 14 4 13 5 12 6 11 7 10 A = Columns 1 through 9 0 0 0 0 0 0 0 0.6000 0.4000 Columns 10 through 15 0 0 0 0 0 0 m = 0.6000 i = 1 2 15 3 14 4 13 5 12 6 11 7 10 8 A = Columns 1 through 9 0 0 0 0 0 0 0 0 0.4000 Columns 10 through 15 0 0 0 0 0 0 m = 0.4000 i = 1 2 15 3 14 4 13 5 12 6 11 7 10 8 9 A = 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 b = -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))

row = 1 col = 1 A = 8.8584 m = 8.8584 i = 1 A = 0 b = 12

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

row = 1 col = 6 A = 200 199 198 197 196 195 m = 200 i = 1 A = 0 199 198 197 196 195 m = 199 i = 1 2 A = 0 0 198 197 196 195 m = 198 i = 1 2 3 A = 0 0 0 197 196 195 m = 197 i = 1 2 3 4 A = 0 0 0 0 196 195 m = 196 i = 1 2 3 4 5 A = 0 0 0 0 0 195 m = 195 i = 1 2 3 4 5 6 A = 0 0 0 0 0 0 b = -100 -99 -98 -97 -96 -95