Cody

Solution 615021

Submitted on 9 Apr 2015 by Jonathan Campelli
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 t2 = 1 2 2 3 3 ans = 1 2 2 3 3 ans = 3 3 4 4 4 5 5 5 5 6

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

trades = 1 2 3 -5 t2 = 1 2 3 ans = 1 2 3

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 t2 = 1 2 3 4 5 6 ans = 1 2 3 4 5 6 ans = 3 4 5 6 7 5 6 7 8 7 8 9 9 10 11 ans = 6 7 8 9 8 9 10 10 11 12 9 10 11 11 12 13 12 13 14 15 ans = 10 11 12 12 13 14 13 14 15 16 14 15 16 17 18 ans = 15 16 17 18 19 20 ans = 21

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 t2 = 1 2 3 3 4 5 5 ans = 1 2 3 3 4 5 5 ans = 3 4 4 5 6 6 5 5 6 7 7 6 7 8 8 7 8 8 9 9 10 ans = 6 6 7 8 8 7 8 9 9 8 9 9 10 10 11 8 9 10 10 9 10 10 11 11 12 10 11 11 12 12 13 12 12 13 14