Cody

Solution 2214089

Submitted on 16 Apr 2020 by Yaroslav Br
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
trades = [1 3 -4 2 -1 2 3] y_correct = 2; assert(isequal(trade_profit(trades),y_correct))

trades = 1 3 -4 2 -1 2 3 z = 3 3 2 2 1 -1 -4 b = 0 i = 1 b = 3 i = 2 b = 6 i = 3 i = 2

2   Pass
trades = [1 2 3 -5] y_correct = 1; assert(isequal(trade_profit(trades),y_correct))

trades = 1 2 3 -5 z = 3 2 1 -5 b = 0 i = 1 b = 3 i = 2 i = 1

3   Pass
trades = [1 2 3 4 5 6] y_correct = 6; assert(isequal(trade_profit(trades),y_correct))

trades = 1 2 3 4 5 6 z = 6 5 4 3 2 1 b = 0 i = 1 b = 6 i = 2 b = 11 i = 3 b = 15 i = 4 b = 18 i = 5 b = 20 i = 6 b = 21 i = 7 i = 6

4   Pass
trades = [-2 3 -4 5 -6 1 2 3 4 5] y_correct = 3; assert(isequal(trade_profit(trades),y_correct))

trades = -2 3 -4 5 -6 1 2 3 4 5 z = 5 5 4 3 3 2 1 -2 -4 -6 b = 0 i = 1 b = 5 i = 2 b = 10 i = 3 b = 14 i = 4 i = 3