Cody

Problem 44787. What can you get for exactly amount of money(harder)

Solution 1677796

Submitted on 21 Nov 2018
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   Fail
v = [ 195 125 260 440 395 290]; s = 570; tic res = buy(v, s); toc assert(sum(res) == s); assert(all(ismember(res, v)))

Error using repelem Out of memory. Type "help memory" for your options. Error in buy (line 2) y = repelem(uint16(v(1)),25e8); Error in Test1 (line 4) res = buy(v, s);

2   Fail
v = [ 150 180 60 40]; s = 210; tic res = buy(v, s); toc assert(sum(res) == s); assert(all(ismember(res, v)))

Error using repelem Out of memory. Type "help memory" for your options. Error in buy (line 2) y = repelem(uint16(v(1)),25e8); Error in Test2 (line 4) res = buy(v, s);

3   Fail
v = [ 150 180 60 40]; s = 1e10; tic res = buy(v, s); toc assert(sum(res) == s); assert(all(ismember(res, v)))

Error using repelem Out of memory. Type "help memory" for your options. Error in buy (line 2) y = repelem(uint16(v(1)),25e8); Error in Test3 (line 4) res = buy(v, s);

4   Fail
v = [123456, 963852, 753159, 7841, 122]; s = 1e10+19; tic res = buy(v, s); toc assert(sum(res) == s); assert(all(ismember(res, v)))

Error using repelem Out of memory. Type "help memory" for your options. Error in buy (line 2) y = repelem(uint16(v(1)),25e8); Error in Test4 (line 4) res = buy(v, s);

5   Fail
v = [319,2770,462,972,8235,6949,3171,9503,345,4388,3816,7656,7952,1869,4898,4456,6464,7094,7547,2761,6798,6551,1627,1190,4984,9598,3404,5853,2239,7513]; s = 1e10+19; tic; res = buy(v, s); toc; assert(sum(res) == s); assert(all(ismember(res, v)))

Error using repelem Out of memory. Type "help memory" for your options. Error in buy (line 2) y = repelem(uint16(v(1)),25e8); Error in Test5 (line 4) res = buy(v, s);

6   Fail
v = [3898,2417,4040,965,1320,9421,9562,5753,598,2348,3532,8212,155,431,1690,6492,7318,6478,4510,5471,2964,7447,1890,6868,1836,3685,6257,7803,812,9294,7758,4868,4359,4468,3064,5086,5108,8177,7949,6444,3787,8116,5329,3508,9391,8760,5502,6225,5871,2078]; s = 1e10+19; tic; res = buy(v, s); toc; assert(sum(res) == s); assert(all(ismember(res, v)))

Error using repelem Out of memory. Type "help memory" for your options. Error in buy (line 2) y = repelem(uint16(v(1)),25e8); Error in Test6 (line 4) res = buy(v, s);

Suggested Problems

More from this Author4

Community Treasure Hunt

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

Start Hunting!