Cody

Problem 43652. "Bubblegum, Bubblegum, in a dish; How many pieces do you wish?"

Solution 1260719

Submitted on 2 Sep 2017
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
players=4; wishes=[3 5 1 6 3 2 4]; winner=2; assert(isequal(bbgwinner(players, wishes),winner))

2   Pass
players=4; wishes=[20 13 7 8 2 16 3]; winner=4; assert(isequal(bbgwinner(players, wishes),winner))

3   Fail
players=2 wishes=[2 1]; winner=2; assert(isequal(bbgwinner(players, wishes),winner))

players = 2

Index exceeds matrix dimensions. Error in bbgwinner (line 4) players=circshift(players,-14-wishes(1)); Error in Test3 (line 4) assert(isequal(bbgwinner(players, wishes),winner))

4   Pass
players=5; wishes=[20 13 7 8 2 16 3 1 2]; winner=4; assert(isequal(bbgwinner(players, wishes),winner))

5   Fail
players=5; wishes=[20 13 7 8 2 16 3 3]; winner=5; assert(isequal(bbgwinner(players, wishes),winner))

Index exceeds matrix dimensions. Error in bbgwinner (line 4) players=circshift(players,-14-wishes(1)); Error in Test5 (line 4) assert(isequal(bbgwinner(players, wishes),winner))

6   Pass
players=20; wishes=123.*[1:39]; winner=17 assert(isequal(bbgwinner(players, wishes),winner))

winner = 17

7   Pass
players=30; wishes=[1:59]; winner=18; assert(isequal(bbgwinner(players, wishes),winner))

8   Fail
players=30; wishes=[1:54 3 1 2 4]; winner=29; assert(isequal(bbgwinner(players, wishes),winner)) %%

Index exceeds matrix dimensions. Error in bbgwinner (line 4) players=circshift(players,-14-wishes(1)); Error in Test8 (line 4) assert(isequal(bbgwinner(players, wishes),winner))

Suggested Problems

More from this Author11

Community Treasure Hunt

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

Start Hunting!