Cody

Problem 128. Sorted highest to lowest?

Solution 1987637

Submitted on 23 Oct 2019 by Le Manh Long Le Manh Long
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 = 1:7; y_correct = 0; assert(isequal(your_fcn_name(x),y_correct))

k = 7 t = 1 2 3 4 5 6 7 h = [] h = 7 h = 7 6 h = 7 6 5 h = 7 6 5 4 h = 7 6 5 4 3 h = 7 6 5 4 3 2 h = 7 6 5 4 3 2 1 f = 1 y = 0

2   Pass
x = [7 6 3]; y_correct = 1; assert(isequal(your_fcn_name(x),y_correct))

k = 3 t = 3 6 7 h = [] h = 7 h = 7 6 h = 7 6 3 f = 3 y = 1

3   Pass
x = [-1 6 3]; y_correct = 0; assert(isequal(your_fcn_name(x),y_correct))

k = 3 t = -1 3 6 h = [] h = 6 h = 6 3 h = 6 3 -1 f = 0 y = 0

4   Pass
x = 20:-2:-4; y_correct = 1; assert(isequal(your_fcn_name(x),y_correct))

k = 13 t = -4 -2 0 2 4 6 8 10 12 14 16 18 20 h = [] h = 20 h = 20 18 h = 20 18 16 h = 20 18 16 14 h = 20 18 16 14 12 h = 20 18 16 14 12 10 h = 20 18 16 14 12 10 8 h = 20 18 16 14 12 10 8 6 h = 20 18 16 14 12 10 8 6 4 h = 20 18 16 14 12 10 8 6 4 2 h = 20 18 16 14 12 10 8 6 4 2 0 h = 20 18 16 14 12 10 8 6 4 2 0 -2 h = 20 18 16 14 12 10 8 6 4 2 0 -2 -4 f = 13 y = 1

Suggested Problems

More from this Author100

Community Treasure Hunt

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

Start Hunting!