Cody

Problem 45450. Don't be Too Greedy!

Solution 2361208

Submitted on 24 May 2020 by William
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
p=[ 10, 4, 1, 2, 5, 2]; t=[ 2, 4, 3, 8, 1, 10]; assert(isequal(greedy_2(p,t),[1,5,2,3,4,6]))

2   Pass
p=[4,2,1, 5, 3, 2, 6]; t=[1,8,2, 3, 1, 4, 2]; assert(isequal(greedy_2(p,t),[1 5 7 4 3 6 2]))

3   Pass
p=[9,10,2,10,7,1,3,6,10,10,2,10]; t=[48 25 41 8 22 46 40 48 33 2 43 47]; assert(isequal(greedy_2(p,t),[10 4 2 5 9 12 1 8 7 3 11 6]))

4   Pass
p=[1,3,1,2,4]; t=[1,4,10,2,5]; assert(isequal(greedy_2(p,t),[1 4 5 2 3]))