Cody

# Problem 3027. Legend of Zelda - Rupee Count (Item Purchase)

Solution 1949621

Submitted on 26 Sep 2019
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
r = [20,5,3,1,0,1,1,0,0,0,0]; i_arr_corr = {'Magic potion','Shovel','Bombs'}; r_rem_corr = 70; [i_arr,r_rem] = rupee_count_items(r); assert(isequal(r_rem,r_rem_corr)); assert(isequal(i_arr,i_arr_corr));

r = 395 t = 4 5 6 i_arr = 1×1 cell array {'Magic potion'} i_arr = 1×2 cell array {'Magic potion'} {'Shovel'} i_arr = 1×3 cell array {'Magic potion'} {'Shovel'} {'Bombs'} r = 70

Assertion failed.

2   Fail
r = [4,0,1,0,0,0,0,0,0,1,5]; i_arr_corr = {'Bow & Arrows','Shield','Magic potion'}; r_rem_corr = 14; [i_arr,r_rem] = rupee_count_items(r); assert(isequal(r_rem,r_rem_corr)); assert(isequal(i_arr,i_arr_corr));

r = 1714 t = 2 3 4 i_arr = 1×1 cell array {'Bow & Arrows'} i_arr = 1×2 cell array {'Bow & Arrows'} {'Shield'} i_arr = 1×3 cell array {'Bow & Arrows'} {'Shield'} {'Magic potion'} r = 14

Assertion failed.

3   Fail
r = [194,27,13,5,3,2,1,0,1,0,1]; i_arr_corr = {'Bow & Arrows','Shield'}; r_rem_corr = 9; [i_arr,r_rem] = rupee_count_items(r); assert(isequal(r_rem,r_rem_corr)); assert(isequal(i_arr,i_arr_corr));

r = 1509 t = 2 3 i_arr = 1×1 cell array {'Bow & Arrows'} i_arr = 1×2 cell array {'Bow & Arrows'} {'Shield'} r = 9

Assertion failed.

4   Fail
r = [254,94,23,11,15,4,7,3,2,0,1]; i_arr_corr = {'Hookshot','Bow & Arrows','Magic potion','Shovel','Bombs'}; r_rem_corr = 49; [i_arr,r_rem] = rupee_count_items(r); assert(isequal(r_rem,r_rem_corr)); assert(isequal(i_arr,i_arr_corr));

r = 4374 t = 1 2 4 5 6 i_arr = 1×1 cell array {'Hookshot'} i_arr = 1×2 cell array {'Hookshot'} {'Bow & Arrows'} i_arr = 1×3 cell array {'Hookshot'} {'Bow & Arrows'} {'Magic potion'} i_arr = 1×4 cell array {'Hookshot'} {'Bow & Arrows'} {'Magic potion'} {'Shovel'} i_arr = 1×5 cell array {'Hookshot'} {'Bow & Arrows'} {'Magic potion'} {'Shovel'} {'Bombs'} r = 49

Assertion failed.

5   Pass
r = [255,94,24,13,15,4,7,3,2,2,1]; i_arr_corr = {'Hookshot','Bow & Arrows','Shield','Magic potion','Shovel','Bombs'}; r_rem_corr = 0; [i_arr,r_rem] = rupee_count_items(r); assert(isequal(r_rem,r_rem_corr)); assert(isequal(i_arr,i_arr_corr));

r = 4825 t = 1 2 3 4 5 6 i_arr = 1×1 cell array {'Hookshot'} i_arr = 1×2 cell array {'Hookshot'} {'Bow & Arrows'} i_arr = 1×3 cell array {'Hookshot'} {'Bow & Arrows'} {'Shield'} i_arr = 1×4 cell array {'Hookshot'} {'Bow & Arrows'} {'Shield'} {'Magic potion'} i_arr = 1×5 cell array {'Hookshot'} {'Bow & Arrows'} {'Shield'} {'Magic potion'} {'Shovel'} i_arr = 1×6 cell array {'Hookshot'} {'Bow & Arrows'} {'Shield'} {'Magic potion'} {'Shovel'} {'Bombs'} r = 0

6   Fail
r = [27,2,1,0,0,0,0,0,0,0,0]; i_arr_corr = {'Bombs'}; r_rem_corr = 22; [i_arr,r_rem] = rupee_count_items(r); assert(isequal(r_rem,r_rem_corr)); assert(isequal(i_arr,i_arr_corr));

r = 47 t = 6 i_arr = 1×1 cell array {'Bombs'} r = 22

Assertion failed.

7   Fail
r_ind = randi(21); r = [r_ind,2,2,1,1,0,0,0,0,0,0]; i_arr_corr = {'Shovel'}; r_rem_corr = r_ind; [i_arr,r_rem] = rupee_count_items(r); assert(isequal(r_rem,r_rem_corr)); assert(isequal(i_arr,i_arr_corr));

r = 102 t = 5 i_arr = 1×1 cell array {'Shovel'} r = 2

Assertion failed.

### Community Treasure Hunt

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

Start Hunting!