Cody

Solution 1212952

Submitted on 15 Jun 2017 by Said BOUREZG
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))

ans = [] ans = 12 ans = 12 9 ans = 12 9 19

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

ans = [] ans = 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))

ans = [] ans = 100 ans = 100 2 ans = 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))

ans = [] ans = 6 ans = 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))

ans = [] ans = 1 ans = 1 1 ans = 1 1 1 ans = 1 1 1 1 ans = 1 1 1 1 1 ans = 1 1 1 1 1 1 ans = 1 1 1 1 1 1 1 ans = 1 1 1 1 1 1 1 1 ans = 1 1 1 1 1 1 1 1 1 ans = 1 1 1 1 1 1 1 1 1 1 ans = 1 1 1 1 1 1 1 1 1 1 1 ans = 1 1 1 1 1 1 1 1 1 1 1 1 ans = 1 1 1 1 1 1 1 1 1 1 1 1 1 ans = 1 1 1 1 1 1 1 1 1 1 1 1 1 1 ans = 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 ans = 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 ans = 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 ans = 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 ans = 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 ans = 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 ans = 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 ans = 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 ans = 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 ans = 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 ans = 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 ans = 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 ans = 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 ans = 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 ans = 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 ans = 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 ans = Columns 1 through 30 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 Column 31 1 ans = Columns 1 through 30 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 Columns 31 through 32 1 1 ans = Columns 1 through 30 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 Columns 31 through 33 1 1 1 ans = Columns 1 through 30 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 Columns 31 through 34 1 1 1 1 ans = Columns 1 through 30 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 Columns 31 through 35 1 1 1 1 1 ans = Columns 1 through 30 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 Columns 31 through 36 1 1 1 1 1 1 ans = Columns 1 through 30 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 Columns 31 through 37 1 1 1 1 1 1 1 ans = Columns 1 through 30 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 Columns 31 through 38 1 1 1 1 1 1 1 1 ans = Columns 1 through 30 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 Columns 31 through 39 1 1 1 1 1 1 1 1 1 ans = Columns 1 through 30 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 Columns 31 through 40 1 1 1 1 1 1 1 1 1 1 ans = Columns 1 through 30 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 Columns 31 through 41 1 1 1 1 1 1 1 1 1 1 1 ans = Columns 1 through 30 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 Columns 31 through 42 1 1 1 1 1 1 1 1 1 1 1 1 ans = Columns 1 through 30 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 Columns 31 through 43 1 1 1 1 1 1 1 1 1 1 1 1 1 ans = Columns 1 through 30 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 Columns 31 through 44 1 1 1 1 1 1 1 1 1 1 1 1 1 1 ans = Columns 1 through 30 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 Columns 31 through 45 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 ans = Columns 1 through 30 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 Columns 31 through 46 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 ans = Columns 1 through 30 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 Columns 31 through 47 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 ans = Columns 1 through 30 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 Columns 31 through 48 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 ans = Columns 1 through 30 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 Columns 31 through 49 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 ans = Columns 1 through 30 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 Columns 31 through 50 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 ans = Columns 1 through 30 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 Columns 31 through 51 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 ans = Columns 1 through 30 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 Columns 31 through 52 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 ans = Columns 1 through 30 1 1 1 1 1 1 1 1 1...

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))

ans = [] ans = 10 ans = 10 10 ans = 10 10 5 ans = 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))

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3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 ans = Columns 1 through 30 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 Column 31 3 ans = Columns 1 through 30 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 Columns 31 through 32 3 3 ans = Columns 1 through 30 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 Columns 31 through 33 3 3 3 ans = Columns 1 through 30 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 Columns 31 through 34 3 3 3 3 ans = Columns 1 through 30 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 Columns 31 through 35 3 3 3 3 3 ans = Columns 1 through 30 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 Columns 31 through 36 3 3 3 3 3 3 ans = Columns 1 through 30 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 Columns 31 through 37 3 3 3 3 3 3 3 ans = Columns 1 through 30 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 Columns 31 through 38 3 3 3 3 3 3 3 3 ans = Columns 1 through 30 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 Columns 31 through 39 3 3 3 3 3 3 3 3 3 ans = Columns 1 through 30 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 Columns 31 through 40 3 3 3 3 3 3 3 3 3 3 ans = Columns 1 through 30 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 Columns 31 through 41 3 3 3 3 3 3 3 3 3 3 3 ans = Columns 1 through 30 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 Columns 31 through 42 3 3 3 3 3 3 3 3 3 3 3 3 ans = Columns 1 through 30 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 Columns 31 through 43 3 3 3 3 3 3 3 3 3 3 3 3 3 ans = Columns 1 through 30 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 Columns 31 through 44 3 3 3 3 3 3 3 3 3 3 3 3 3 3 ans = Columns 1 through 30 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 Columns 31 through 45 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 ans = Columns 1 through 30 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 Columns 31 through 46 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 ans = Columns 1 through 30 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 Columns 31 through 47 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 ans = Columns 1 through 30 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 Columns 31 through 48 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 ans = Columns 1 through 30 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 Columns 31 through 49 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 ans = Columns 1 through 30 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 Columns 31 through 50 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 ans = Columns 1 through 30 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 Columns 31 through 51 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 ans = Columns 1 through 30 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 Columns 31 through 52 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 ans = Columns 1 through 30 3 3 3 3 3 3 3 3 3...