Cody

# Problem 9. Who Has the Most Change?

Solution 2088875

Submitted on 11 Jan 2020 by Ishan Fernando
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
a = [1 2 1 15]; b = 1; assert(isequal(most_change(a),b))

rows = 1 cols = 4 change = 0.2500 change = 0.3500 change = 0.4500 change = 0.6000 cash = 0.6000 cashrows = 1 cashcols = 1 max = 0 maxrow = 0 max = 0.6000 maxrow = 1 b = 1

2   Pass
a = [ 1 2 1 15; 0 8 5 9]; b = 2; assert(isequal(most_change(a),b))

rows = 2 cols = 4 change = 0.2500 change = 0.3500 change = 0.4500 change = 0.6000 cash = 0.6000 change = 0 change = 0.4000 change = 0.9000 change = 0.9900 cash = 0.6000 0.9900 cashrows = 2 cashcols = 1 max = 0 maxrow = 0 max = 0.6000 maxrow = 1 b = 1 max = 0.9900 maxrow = 2 b = 2

3   Pass
a = [ 1 22 1 15; 12 3 13 7; 10 8 23 99]; b = 3; assert(isequal(most_change(a),b))

rows = 3 cols = 4 change = 0.2500 change = 1.3500 change = 1.4500 change = 1.6000 cash = 1.6000 change = 3 change = 3.1500 change = 4.4500 change = 4.5200 cash = 1.6000 4.5200 change = 2.5000 change = 2.9000 change = 5.2000 change = 6.1900 cash = 1.6000 4.5200 6.1900 cashrows = 3 cashcols = 1 max = 0 maxrow = 0 max = 1.6000 maxrow = 1 b = 1 max = 4.5200 maxrow = 2 b = 2 max = 6.1900 maxrow = 3 b = 3

4   Pass
a = [ 1 0 0 0; 0 0 0 24]; b = 1; assert(isequal(most_change(a),b))

rows = 2 cols = 4 change = 0.2500 change = 0.2500 change = 0.2500 change = 0.2500 cash = 0.2500 change = 0 change = 0 change = 0 change = 0.2400 cash = 0.2500 0.2400 cashrows = 2 cashcols = 1 max = 0 maxrow = 0 max = 0.2500 maxrow = 1 b = 1

5   Pass
a = [ 0 1 2 1; 0 2 1 1]; c = 1; assert(isequal(most_change(a),c))

rows = 2 cols = 4 change = 0 change = 0.0500 change = 0.2500 change = 0.2600 cash = 0.2600 change = 0 change = 0.1000 change = 0.2000 change = 0.2100 cash = 0.2600 0.2100 cashrows = 2 cashcols = 1 max = 0 maxrow = 0 max = 0.2600 maxrow = 1 b = 1

6   Pass
% There is a lot of confusion about this problem. Watch this. a = [0 1 0 0; 0 0 1 0]; c = 2; assert(isequal(most_change(a),c)) % Now go back and read the problem description carefully.

rows = 2 cols = 4 change = 0 change = 0.0500 change = 0.0500 change = 0.0500 cash = 0.0500 change = 0 change = 0 change = 0.1000 change = 0.1000 cash = 0.0500 0.1000 cashrows = 2 cashcols = 1 max = 0 maxrow = 0 max = 0.0500 maxrow = 1 b = 1 max = 0.1000 maxrow = 2 b = 2

7   Pass
a = [ 2 1 1 1; 1 2 1 1; 1 1 2 1; 1 1 1 2; 4 0 0 0]; c = 5; assert(isequal(most_change(a),c))

rows = 5 cols = 4 change = 0.5000 change = 0.5500 change = 0.6500 change = 0.6600 cash = 0.6600 change = 0.2500 change = 0.3500 change = 0.4500 change = 0.4600 cash = 0.6600 0.4600 change = 0.2500 change = 0.3000 change = 0.5000 change = 0.5100 cash = 0.6600 0.4600 0.5100 change = 0.2500 change = 0.3000 change = 0.4000 change = 0.4200 cash = 0.6600 0.4600 0.5100 0.4200 change = 1 change = 1 change = 1 change = 1 cash = 0.6600 0.4600 0.5100 0.4200 1.0000 cashrows = 5 cashcols = 1 max = 0 maxrow = 0 max = 0.6600 maxrow = 1 b = 1 max = 1 maxrow = 5 b = 5

### Community Treasure Hunt

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

Start Hunting!