Cody

Solution 1122324

Submitted on 13 Feb 2017 by Jihye Sofia Seo
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 = [2 12 4 6 9 4 3 1 19 7]; y_correct = [12 9 19]; assert(isequal(find_peak(x),y_correct))

fD = 10 -8 2 3 -5 -1 -2 18 -12 inc = 1 3 4 8 dec = 2 5 6 7 9 peaks = 1 4 8 y = 12 9 19

2   Pass
x = [ones(1,9) 10 zeros(1,10)]; y_correct = 10; assert(isequal(find_peak(x),y_correct))

fD = 0 0 0 0 0 0 0 0 9 -10 0 0 0 0 0 0 0 0 0 inc = 9 dec = 10 peaks = 9 y = 10

3   Pass
x = [1:10 100 -4 2 0 0 4 5 6 0]; y_correct = [100 2 6]; assert(isequal(find_peak(x),y_correct))

fD = 1 1 1 1 1 1 1 1 1 90 -104 6 -2 0 4 1 1 -6 inc = 1 2 3 4 5 6 7 8 9 10 12 15 16 17 dec = 11 13 18 peaks = 10 12 17 y = 100 2 6

4   Pass
x = [1:5 6:-1:1 1:3 4:-1:0]; y_correct = [6 4]; assert(isequal(find_peak(x),y_correct))

fD = 1 1 1 1 1 -1 -1 -1 -1 -1 0 1 1 1 -1 -1 -1 -1 inc = 1 2 3 4 5 12 13 14 dec = 6 7 8 9 10 15 16 17 18 peaks = 5 14 y = 6 4

5   Pass
x = zeros(1,10000); x(2:10:9992) = 1; y_correct = ones(1,1000); assert(isequal(find_peak(x),y_correct))

fD = Columns 1 through 29 1 -1 0 0 0 0 0 0 0 0 1 -1 0 0 0 0 0 0 0 0 1 -1 0 0 0 0 0 0 0 Columns 30 through 58 0 1 -1 0 0 0 0 0 0 0 0 1 -1 0 0 0 0 0 0 0 0 1 -1 0 0 0 0 0 0 Columns 59 through 87 0 0 1 -1 0 0 0 0 0 0 0 0 1 -1 0 0 0 0 0 0 0 0 1 -1 0 0 0 0 0 Columns 88 through 116 0 0 0 1 -1 0 0 0 0 0 0 0 0 1 -1 0 0 0 0 0 0 0 0 1 -1 0 0 0 0 Columns 117 through 145 0 0 0 0 1 -1 0 0 0 0 0 0 0 0 1 -1 0 0 0 0 0 0 0 0 1 -1 0 0 0 Columns 146 through 174 0 0 0 0 0 1 -1 0 0 0 0 0 0 0 0 1 -1 0 0 0 0 0 0 0 0 1 -1 0 0 Columns 175 through 203 0 0 0 0 0 0 1 -1 0 0 0 0 0 0 0 0 1 -1 0 0 0 0 0 0 0 0 1 -1 0 Columns 204 through 232 0 0 0 0 0 0 0 1 -1 0 0 0 0 0 0 0 0 1 -1 0 0 0 0 0 0 0 0 1 -1 Columns 233 through 261 0 0 0 0 0 0 0 0 1 -1 0 0 0 0 0 0 0 0 1 -1 0 0 0 0 0 0 0 0 1 Columns 262 through 290 -1 0 0 0 0 0 0 0 0 1 -1 0 0 0 0 0 0 0 0 1 -1 0 0 0 0 0 0 0 0 Columns 291 through 319 1 -1 0 0 0 0 0 0 0 0 1 -1 0 0 0 0 0 0 0 0 1 -1 0 0 0 0 0 0 0 Columns 320 through 348 0 1 -1 0 0 0 0 0 0 0 0 1 -1 0 0 0 0 0 0 0 0 1 -1 0 0 0 0 0 0 Columns 349 through 377 0 0 1 -1 0 0 0 0 0 0 0 0 1 -1 0 0 0 0 0 0 0 0 1 -1 0 0 0 0 0 Columns 378 through 406 0 0 0 1 -1 0 0 0 0 0 0 0 0 1 -1 0 0 0 0 0 0 0 0 1 -1 0 0 0 0 Columns 407 through 435 0 0 0 0 1 -1 0 0 0 0 0 0 0 0 1 -1 0 0 0 0 0 0 0 0 1 -1 0 0 0 Columns 436 through 464 0 0 0 0 0 1 -1 0 0 0 0 0 0 0 0 1 -1 0 0 0 0 0 0 0 0 1 -1 0 0 Columns 465 through 493 0 0 0 0 0 0 1 -1 0 0 0 0 0 0 0 0 1 -1 0 0 0 0 0 0 0 0 1 -1 0 Columns 494 through 522 0 0 0 0 0 0 0 1 -1 0 0 0 0 0 0 0 0 1 -1 0 0 0 0 0 0 0 0 1 -1 Columns 523 through 551 0 0 0 0 0 0 0 0 1 -1 0 0 0 0 0 0 0 0 1 -1 0 0 0 0 0 0 0 0 1 Columns 552 through 580 -1 0 0 0 0 0 0 0 0 1 -1 0 0 0 0 0 0 0 0 1 -1 0 0 0 0 0 0 0 0 Columns 581 through 609 1 -1 0 0 0 0 0 0 0 0 1 -1 0 0 0 0 0 0 0 0 1 -1 0 0 0 0 0 0 0 Columns 610 through 638 0 1 -1 0 0 0 0 0 0 0 0 1 -1 0 0 0 0 0 0 0 0 1 -1 0 0 0 0 0 0 Columns 639 through 667 0 0 1 -1 0 0 0 0 0 0 0 0 1 -1 0 0 0 0 0 0 0 0 1 -1 0 0 0 0 0 Columns 668 through 696 0 0 0 1 -1 0 0 0 0 0 0 0 0 1 -1 0 0 0 0 0 0 0 0 1 -1 0 0 0 0 Columns 697 through 725 0 0 0 0 1 -1 0 0 0 0 0 0 0 0 1 -1 0 0 0 0 0 0 0 0 1 -1 0 0 0 Columns 726 through 754 0 0 0 0 0 1 -1 0 0 0 0 0 0 0 0 1 -1 0 0 0 0 0 0 0 0 1 -1 0 0 Columns 755 through 783 0 0 0 0 0 0 1 -1 0 0 0 0 0 0 0 0 1 -1 0 0 0 0 0 0 0 0 1 -1 0 Columns 784 through 812 0 0 0 0 0 0 0 1 -1 0 0 0 0 0 0 0 0 1 -1 0 0 0 0 0 0 0 0 1 -1 Columns 813 through 841 0 0 0 0 0 0 0 0 1 -1 0 0 0 0 0 0 0 0 1 -1 0 0 0 0 0 0 0 0 1 Columns 842 through 870 -1 0 0 0 0 0 0 0 0 1 -1 0 0 0 0 0 0 0 0 1 -1 0 0 0 0 0 0 0 0 Columns 871 through 899 1 -1 0 0 0 0 0 0 0 0 1 -1 0 0 0 0 0 0 0 0 1 -1 0 0 0 0 0 0 0 Columns 900 through 928 0 1 -1 0 0 0 0 0 0 0 0 1 -1 0 0 0 0 0 0 0 0 1 -1 0 0 0 0 0 0 Columns 929 through 957 0 0 1 -1 0 0 0 0 0 0 0 0 1 -1 0 0 0 0 0 0 0 0 1 -1 0 0 0 0 0 Columns 958 through 986 0 0 0 1 -1 0 0 0 0 0 0 0 0 1 -1 0 0 0 0 0 0 0 0 1 -1 0 0 0 0 Columns 987 through 1015 0 0 0 0 1 -1 0 0 0 0 0 0 0 0 1 -1 0 0 0 0 0 0 0 0 1 -1 0 0 0 Columns 1016 through 1044 0 0 0 0 0 1 -1 0 0 0 0 0 0 0 0 1 -1 0 0 0 0 0 0 0 0 1 -1 0 0 Columns 1045 through 1073 0 0 0 0 0 0 1 -1 0 0 0 0 0 0 0 0 1 -1 0 0 0 0 0 0 0 0 1 -1 0 Columns 1074 through 1102 0 0 0 0 0 0 0 1 -1 0 0 0 0 0 0 0 0 1 -1 0 0 0 0 0 0 0 0 1 -1 Columns 1103 through 1131 0 0 0 0 0 0 0 0 1 -1 0 0 0 0 0 0 0 0 1 -1 0 0 0 0 0 0 0 0 1 Columns 1132 through 1160 -1 0 0 0 0 0 0 0 0 1 -1 0 0 0 0 0 0 0 0 1 -1 0 0 0 0 0 0 0 0 Columns 1161 through 1189 1 -1 0 0 0 0 0 0 0 0 1 -1 0 0 0 0 0 0 0 0 1 -1 0 0 0 0 0 0 0 Columns 1190 through 1218 0 1 -1 0 0 0 0 0 0 0 0 1 -1 0 0 0 0 0 0 0 0 1 -1 0 0 0 0 0 0 Columns 1219 through 1247 0 0 1 -1 0 0 0 0 0 0 0 0 1 -1 0 0 0 0 0 0 0 0 1 -1 0 0 0 0 0 Columns 1248 through 1276 0 0 0 1 -1 0 0 0 0 0 0 0 0 1 -1 0 0 0 0 0 0 0 0 1 -1 0 0 0 0 Columns 1277 through 1305 0 0 0 0 1 -1 0 0 0 0 0 0 0 0 1 -1 0 0 0 0 0 0 0 0 1 -1 0 0 0 Columns 1306 through 1334 0 0 0 0 0 1 -1 0 0 0 0 0 0 0 0 1 -1 0 0 0 0 0 0 0 0 1 -1 0 0 Columns 1335 through 1363 0 0 0 0 0 0 1 -1 0 0 0 0 0 0 0 0 1 -1 0 0 0 0 0 0 0 0 1 -1 0 Columns 1364 through 1392 0 0 0 0 0 0 0 1 -1 0 0 0 0 0 0 0 0 1 -1 0 0 0 0 0 0 0 0 1 -1 Columns 1393 through 1421 0 0 0 0 0 0 0 0 1 -1 0 0 0 0 0 0 0 0 1 -1 0 0 0 0 0 0 0 0 1 Columns 1422 through 145...

6   Pass
x = [1 2 4 7 10 9 8 9 10 9 7 4 5 3 1 -2 -3 0 1 0]; y_correct = [10 10 5 1]; assert(isequal(find_peak(x),y_correct))

fD = 1 2 3 3 -1 -1 1 1 -1 -2 -3 1 -2 -2 -3 -1 3 1 -1 inc = 1 2 3 4 7 8 12 17 18 dec = 5 6 9 10 11 13 14 15 16 19 peaks = 4 8 12 18 y = 10 10 5 1

7   Pass
x = [repmat([1 2 3 2 1],[1,1000])]; y_correct = 3*ones(1,1000); assert(isequal(find_peak(x),y_correct))

fD = Columns 1 through 29 1 1 -1 -1 0 1 1 -1 -1 0 1 1 -1 -1 0 1 1 -1 -1 0 1 1 -1 -1 0 1 1 -1 -1 Columns 30 through 58 0 1 1 -1 -1 0 1 1 -1 -1 0 1 1 -1 -1 0 1 1 -1 -1 0 1 1 -1 -1 0 1 1 -1 Columns 59 through 87 -1 0 1 1 -1 -1 0 1 1 -1 -1 0 1 1 -1 -1 0 1 1 -1 -1 0 1 1 -1 -1 0 1 1 Columns 88 through 116 -1 -1 0 1 1 -1 -1 0 1 1 -1 -1 0 1 1 -1 -1 0 1 1 -1 -1 0 1 1 -1 -1 0 1 Columns 117 through 145 1 -1 -1 0 1 1 -1 -1 0 1 1 -1 -1 0 1 1 -1 -1 0 1 1 -1 -1 0 1 1 -1 -1 0 Columns 146 through 174 1 1 -1 -1 0 1 1 -1 -1 0 1 1 -1 -1 0 1 1 -1 -1 0 1 1 -1 -1 0 1 1 -1 -1 Columns 175 through 203 0 1 1 -1 -1 0 1 1 -1 -1 0 1 1 -1 -1 0 1 1 -1 -1 0 1 1 -1 -1 0 1 1 -1 Columns 204 through 232 -1 0 1 1 -1 -1 0 1 1 -1 -1 0 1 1 -1 -1 0 1 1 -1 -1 0 1 1 -1 -1 0 1 1 Columns 233 through 261 -1 -1 0 1 1 -1 -1 0 1 1 -1 -1 0 1 1 -1 -1 0 1 1 -1 -1 0 1 1 -1 -1 0 1 Columns 262 through 290 1 -1 -1 0 1 1 -1 -1 0 1 1 -1 -1 0 1 1 -1 -1 0 1 1 -1 -1 0 1 1 -1 -1 0 Columns 291 through 319 1 1 -1 -1 0 1 1 -1 -1 0 1 1 -1 -1 0 1 1 -1 -1 0 1 1 -1 -1 0 1 1 -1 -1 Columns 320 through 348 0 1 1 -1 -1 0 1 1 -1 -1 0 1 1 -1 -1 0 1 1 -1 -1 0 1 1 -1 -1 0 1 1 -1 Columns 349 through 377 -1 0 1 1 -1 -1 0 1 1 -1 -1 0 1 1 -1 -1 0 1 1 -1 -1 0 1 1 -1 -1 0 1 1 Columns 378 through 406 -1 -1 0 1 1 -1 -1 0 1 1 -1 -1 0 1 1 -1 -1 0 1 1 -1 -1 0 1 1 -1 -1 0 1 Columns 407 through 435 1 -1 -1 0 1 1 -1 -1 0 1 1 -1 -1 0 1 1 -1 -1 0 1 1 -1 -1 0 1 1 -1 -1 0 Columns 436 through 464 1 1 -1 -1 0 1 1 -1 -1 0 1 1 -1 -1 0 1 1 -1 -1 0 1 1 -1 -1 0 1 1 -1 -1 Columns 465 through 493 0 1 1 -1 -1 0 1 1 -1 -1 0 1 1 -1 -1 0 1 1 -1 -1 0 1 1 -1 -1 0 1 1 -1 Columns 494 through 522 -1 0 1 1 -1 -1 0 1 1 -1 -1 0 1 1 -1 -1 0 1 1 -1 -1 0 1 1 -1 -1 0 1 1 Columns 523 through 551 -1 -1 0 1 1 -1 -1 0 1 1 -1 -1 0 1 1 -1 -1 0 1 1 -1 -1 0 1 1 -1 -1 0 1 Columns 552 through 580 1 -1 -1 0 1 1 -1 -1 0 1 1 -1 -1 0 1 1 -1 -1 0 1 1 -1 -1 0 1 1 -1 -1 0 Columns 581 through 609 1 1 -1 -1 0 1 1 -1 -1 0 1 1 -1 -1 0 1 1 -1 -1 0 1 1 -1 -1 0 1 1 -1 -1 Columns 610 through 638 0 1 1 -1 -1 0 1 1 -1 -1 0 1 1 -1 -1 0 1 1 -1 -1 0 1 1 -1 -1 0 1 1 -1 Columns 639 through 667 -1 0 1 1 -1 -1 0 1 1 -1 -1 0 1 1 -1 -1 0 1 1 -1 -1 0 1 1 -1 -1 0 1 1 Columns 668 through 696 -1 -1 0 1 1 -1 -1 0 1 1 -1 -1 0 1 1 -1 -1 0 1 1 -1 -1 0 1 1 -1 -1 0 1 Columns 697 through 725 1 -1 -1 0 1 1 -1 -1 0 1 1 -1 -1 0 1 1 -1 -1 0 1 1 -1 -1 0 1 1 -1 -1 0 Columns 726 through 754 1 1 -1 -1 0 1 1 -1 -1 0 1 1 -1 -1 0 1 1 -1 -1 0 1 1 -1 -1 0 1 1 -1 -1 Columns 755 through 783 0 1 1 -1 -1 0 1 1 -1 -1 0 1 1 -1 -1 0 1 1 -1 -1 0 1 1 -1 -1 0 1 1 -1 Columns 784 through 812 -1 0 1 1 -1 -1 0 1 1 -1 -1 0 1 1 -1 -1 0 1 1 -1 -1 0 1 1 -1 -1 0 1 1 Columns 813 through 841 -1 -1 0 1 1 -1 -1 0 1 1 -1 -1 0 1 1 -1 -1 0 1 1 -1 -1 0 1 1 -1 -1 0 1 Columns 842 through 870 1 -1 -1 0 1 1 -1 -1 0 1 1 -1 -1 0 1 1 -1 -1 0 1 1 -1 -1 0 1 1 -1 -1 0 Columns 871 through 899 1 1 -1 -1 0 1 1 -1 -1 0 1 1 -1 -1 0 1 1 -1 -1 0 1 1 -1 -1 0 1 1 -1 -1 Columns 900 through 928 0 1 1 -1 -1 0 1 1 -1 -1 0 1 1 -1 -1 0 1 1 -1 -1 0 1 1 -1 -1 0 1 1 -1 Columns 929 through 957 -1 0 1 1 -1 -1 0 1 1 -1 -1 0 1 1 -1 -1 0 1 1 -1 -1 0 1 1 -1 -1 0 1 1 Columns 958 through 986 -1 -1 0 1 1 -1 -1 0 1 1 -1 -1 0 1 1 -1 -1 0 1 1 -1 -1 0 1 1 -1 -1 0 1 Columns 987 through 1015 1 -1 -1 0 1 1 -1 -1 0 1 1 -1 -1 0 1 1 -1 -1 0 1 1 -1 -1 0 1 1 -1 -1 0 Columns 1016 through 1044 1 1 -1 -1 0 1 1 -1 -1 0 1 1 -1 -1 0 1 1 -1 -1 0 1 1 -1 -1 0 1 1 -1 -1 Columns 1045 through 1073 0 1 1 -1 -1 0 1 1 -1 -1 0 1 1 -1 -1 0 1 1 -1 -1 0 1 1 -1 -1 0 1 1 -1 Columns 1074 through 1102 -1 0 1 1 -1 -1 0 1 1 -1 -1 0 1 1 -1 -1 0 1 1 -1 -1 0 1 1 -1 -1 0 1 1 Columns 1103 through 1131 -1 -1 0 1 1 -1 -1 0 1 1 -1 -1 0 1 1 -1 -1 0 1 1 -1 -1 0 1 1 -1 -1 0 1 Columns 1132 through 1160 1 -1 -1 0 1 1 -1 -1 0 1 1 -1 -1 0 1 1 -1 -1 0 1 1 -1 -1 0 1 1 -1 -1 0 Columns 1161 through 1189 1 1 -1 -1 0 1 1 -1 -1 0 1 1 -1 -1 0 1 1 -1 -1 0 1 1 -1 -1 0 1 1 -1 -1 Columns 1190 through 1218 0 1 1 -1 -1 0 1 1 -1 -1 0 1 1 -1 -1 0 1 1 -1 -1 0 1 1 -1 -1 0 1 1 -1 Columns 1219 through 1247 -1 0 1 1 -1 -1 0 1 1 -1 -1 0 1 1 -1 -1 0 1 1 -1 -1 0 1 1 -1 -1 0 1 1 Columns 1248 through 1276 -1 -1 0 1 1 -1 -1 0 1 1 -1 -1 0 1 1 -1 -1 0 1 1 -1 -1 0 1 1 -1 -1 0 1 Columns 1277 through 1305 1 -1 -1 0 1 1 -1 -1 0 1 1 -1 -1 0 1 1 -1 -1 0 1 1 -1 -1 0 1 1 -1 -1 0 Columns 1306 through 1334 1 1 -1 -1 0 1 1 -1 -1 0 1 1 -1 -1 0 1 1 -1 -1 0 1 1 -1 -1 0 1 1 -1 -1 Columns 1335 through 1363 0 1 1 -1 -1 0 1 1 -1 -1 0 1 1 -1 -1 0 1 1 -1 -1 0 1 1 -1 -1 0 1 1 -1 Columns 1364 through 1392 -1 0 1 1 -1 -1 0 1 1 -1 -1 0 1 1 -1 -1 0 1 1 -1 -1 0 1 1 -1 -1 0 1 1 Columns 1393 through 1421 -1 -1 0 1 1 -1 -1 0 1 1 -1 -1 0 1 1 -1 -1 0 1 1 -1 -1 0 1 1 -1 -1 0 1 Columns 1422 through 145...