-
3 Comments
Not sure the test suite is correct on this problem. If I have 1 dime, two nickels and a penny then I will have (21 cents). If I have two dimes, a nickel and a penny, I will have 26 cents. So the second is larger, but the test suite is testing that the row should be 1. Both 5 and 6 seem off.
Hello I am a South African newbie, and this is how I solved it
function b = most_change(a)
a(:,1) = 0.25 .* a(:,1);
a(:,2) = 0.05 .* a(:,2);
a(:,3) = 0.1 .* a(:,3);
a(:,4) = 0.01 .* a(:,4);
a = a';
vecsum = sum(a);
vecsum = vecsum';
[M,I] = max(vecsum);
b = I;
end
Almost had it!! The ordering has nickel and dime switched. So just change v to
[.25 .05 .1 .01] and you're done.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!