Cody

# Problem 3100. Rumis Scorer 2

Solution 2003962

Submitted on 5 Nov 2019 by Charles Juenger
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
clear board board(:,:,1) = ['rrbrbbr';'rbrbbrb';'bbrbbrb';'rbrrrbr';'bbrbbbr';'bbbrrbr']; board(:,:,2) = ['brbbbrb';'rrrbbbr';'bbrbrbr';'brbrbrr';'rbrrrbr';'brbbbbr']; %blue wins 22 to 20 assert(isequal(rumis_scorer2(board),'b'))

b = [] c = 6×7 logical array 1 1 0 1 0 0 1 1 0 1 0 0 1 0 0 0 1 0 0 1 0 1 0 1 1 1 0 1 0 0 1 0 0 0 1 0 0 0 1 1 0 1 b = 'r' c = 6×7 logical array 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 b = 'r' c = 6×7 logical array 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 b = 'r' c = 6×7 logical array 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 b = 'r' c = 6×7 logical array 0 0 1 0 1 1 0 0 1 0 1 1 0 1 1 1 0 1 1 0 1 0 1 0 0 0 1 0 1 1 0 1 1 1 0 1 1 1 0 0 1 0 b = 'rb' c = 6×7 logical array 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 b = 'rb' M = 22 I = 2 winner = 'b'

2   Pass
clear board board(:,:,1) = ['ppbrpbr';'rbrpbrb';'bbrbbrb';'rbrrppr';'bbrpbbr';'bbprrbr']; board(:,:,2) = ['brbpbrb';'rrpbbpr';'pprbrbr';'brprbrr';'rbrrpbr';'brppbbr']; %red wins 18 to 15 (b) to 9 (p) assert(isequal(rumis_scorer2(board),'r'))

b = [] c = 6×7 logical array 0 0 0 1 0 0 1 1 0 1 0 0 1 0 0 0 1 0 0 1 0 1 0 1 1 0 0 1 0 0 1 0 0 0 1 0 0 0 1 1 0 1 b = 'r' c = 6×7 logical array 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 b = 'r' c = 6×7 logical array 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 b = 'r' c = 6×7 logical array 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 b = 'r' c = 6×7 logical array 0 0 1 0 0 1 0 0 1 0 0 1 0 1 1 1 0 1 1 0 1 0 1 0 0 0 0 0 1 1 0 0 1 1 0 1 1 0 0 0 1 0 b = 'rb' c = 6×7 logical array 1 1 0 0 1 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 1 0 0 0 0 1 0 0 0 0 0 1 0 0 0 0 b = 'rbp' M = 18 I = 1 winner = 'r'

3   Pass
clear board board(:,:,1) = ['brbrb';'rrrbb';'bggob';'ggoro';'bbrbr']; board(:,:,2) = ['bobrb';'roggr';'bogor';'bgoor';'rgrrr']; board(:,:,3) = ['bobrg';'rrbgr';'rooor';'brbrg';'rgrrr']; board(:,:,4) = ['borbg';'rrbbr';'bbrbr';'bboog';'rgrog']; board(:,:,5) = ['robbr';'bbror';'borbr';'rrobb';'boobg']; %blue wins 10 to 8 (r) to 6 (o) to 1 (g) assert(isequal(rumis_scorer2(board),'b'))

b = [] c = 5×5 logical array 0 1 0 1 0 1 1 1 0 0 0 0 0 0 0 0 0 0 1 0 0 0 1 0 1 b = 'r' c = 5×5 logical array 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 1 0 1 0 0 0 0 0 b = 'ro' c = 5×5 logical array 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 b = 'ro' c = 5×5 logical array 0 0 0 0 0 0 0 0 0 0 0 1 1 0 0 1 1 0 0 0 0 0 0 0 0 b = 'rog' c = 5×5 logical array 1 0 1 0 1 0 0 0 1 1 1 0 0 0 1 0 0 0 0 0 1 1 0 1 0 b = 'rogb' c = 5×5 logical array 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 b = 'rogb' M = 10 I = 4 winner = 'b'

4   Pass
clear board board(:,:,1) = ['rrbrryr';'rbrrryb';'brrrbyb';'rbrbyyr';'rbrbryr';'brrrybr']; board(:,:,2) = ['brbybrb';'rbybbbr';'bbrbrbr';'brbryrr';'rbrrbbr';'brbbybr']; board(:,:,3) = ['byyybry';'ybbbyyr';'bbrbyyr';'brbyyrr';'rbyyybr';'brybybr']; %yellow wins 16 to 15 (b) to 11 (r) assert(isequal(rumis_scorer2(board),'y'))

b = [] c = 6×7 logical array 1 1 0 1 1 0 1 1 0 1 1 1 0 0 0 1 1 1 0 0 0 1 0 1 0 0 0 1 1 0 1 0 1 0 1 0 1 1 1 0 0 1 b = 'r' c = 6×7 logical array 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 b = 'r' c = 6×7 logical array 0 0 0 0 0 1 0 0 0 0 0 0 1 0 0 0 0 0 0 1 0 0 0 0 0 1 1 0 0 0 0 0 0 1 0 0 0 0 0 1 0 0 b = 'ry' c = 6×7 logical array 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 b = 'ry' c = 6×7 logical array 0 0 1 0 0 0 0 0 1 0 0 0 0 1 1 0 0 0 1 0 1 0 1 0 1 0 0 0 0 1 0 1 0 0 0 1 0 0 0 0 1 0 b = 'ryb' c = 6×7 logical array 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 b = 'ryb' M = 16 I = 2 winner = 'y'

5   Pass
clear board board(:,:,1) = ['prbrby';'pprbby';'bggoyb';'gpyoro';'bppbyr']; board(:,:,2) = ['pobrby';'rogygr';'bogoyr';'bgyoor';'rgyyyr']; board(:,:,3) = ['ppbrgy';'rpybgr';'roooyr';'brybrg';'rgryrr']; board(:,:,4) = ['borbgy';'rpbybr';'bbrbry';'bbyoog';'rgrpog']; board(:,:,5) = ['robbry';'bprory';'borbry';'rroybb';'booybg']; board(:,:,6) = ['oobyry';'bpryor';'bopbyr';'rooppb';'boobyg']; %orange wins 8 to 7 (b) to 5 (r,y) to 4 (p) to 1 (g) assert(isequal(rumis_scorer2(board),'o'))

b = [] c = 5×6 logical array 0 1 0 1 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 1 b = 'r' c = 5×6 logical array 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 1 0 1 0 0 0 0 0 0 b = 'ro' c = 5×6 logical array 0 0 0 0 0 1 0 0 0 0 0 1 0 0 0 0 1 0 0 0 1 0 0 0 0 0 0 0 1 0 b = 'roy' c = 5×6 logical array 0 0 0 0 0 0 0 0 0 0 0 0 0 1 1 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 b = 'royg' c = 5×6 logical array 0 0 1 0 1 0 0 0 0 1 1 0 1 0 0 0 0 1 0 0 0 0 0 0 1 0 0 1 0 0 b = 'roygb' c = 5×6 logical array 1 0 0 0 0 0 1 1 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 1 1 0 0 0 b = 'roygbp' M = 8 I = 2 winner = 'o'

6   Pass
ind = randi(5); switch ind case 1 clear board board(:,:,1) = ['rrbrbbr';'rbrbbrb';'bbrbbrb';'rbrrrbr';'bbrbbbr';'bbbrrbr']; board(:,:,2) = ['brbbbrb';'rrrbbbr';'bbrbrbr';'brbrbrr';'rbrrrbr';'brbbbbr']; assert(isequal(rumis_scorer2(board),'b')) case 2 clear board board(:,:,1) = ['ppbrpbr';'rbrpbrb';'bbrbbrb';'rbrrppr';'bbrpbbr';'bbprrbr']; board(:,:,2) = ['brbpbrb';'rrpbbpr';'pprbrbr';'brprbrr';'rbrrpbr';'brppbbr']; assert(isequal(rumis_scorer2(board),'r')) case 3 clear board board(:,:,1) = ['brbrb';'rrrbb';'bggob';'ggoro';'bbrbr']; board(:,:,2) = ['bobrb';'roggr';'bogor';'bgoor';'rgrrr']; board(:,:,3) = ['bobrg';'rrbgr';'rooor';'brbrg';'rgrrr']; board(:,:,4) = ['borbg';'rrbbr';'bbrbr';'bboog';'rgrog']; board(:,:,5) = ['robbr';'bbror';'borbr';'rrobb';'boobg']; assert(isequal(rumis_scorer2(board),'b')) case 4 clear board board(:,:,1) = ['rrbrryr';'rbrrryb';'brrrbyb';'rbrbyyr';'rbrbryr';'brrrybr']; board(:,:,2) = ['brbybrb';'rbybbbr';'bbrbrbr';'brbryrr';'rbrrbbr';'brbbybr']; board(:,:,3) = ['byyybry';'ybbbyyr';'bbrbyyr';'brbyyrr';'rbyyybr';'brybybr']; assert(isequal(rumis_scorer2(board),'y')) case 5 clear board board(:,:,1) = ['prbrby';'pprbby';'bggoyb';'gpyoro';'bppbyr']; board(:,:,2) = ['pobrby';'rogygr';'bogoyr';'bgyoor';'rgyyyr']; board(:,:,3) = ['ppbrgy';'rpybgr';'roooyr';'brybrg';'rgryrr']; board(:,:,4) = ['borbgy';'rpbybr';'bbrbry';'bbyoog';'rgrpog']; board(:,:,5) = ['robbry';'bprory';'borbry';'rroybb';'booybg']; board(:,:,6) = ['oobyry';'bpryor';'bopbyr';'rooppb';'boobyg']; assert(isequal(rumis_scorer2(board),'o')) end

b = [] c = 5×6 logical array 0 1 0 1 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 1 b = 'r' c = 5×6 logical array 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 1 0 1 0 0 0 0 0 0 b = 'ro' c = 5×6 logical array 0 0 0 0 0 1 0 0 0 0 0 1 0 0 0 0 1 0 0 0 1 0 0 0 0 0 0 0 1 0 b = 'roy' c = 5×6 logical array 0 0 0 0 0 0 0 0 0 0 0 0 0 1 1 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 b = 'royg' c = 5×6 logical array 0 0 1 0 1 0 0 0 0 1 1 0 1 0 0 0 0 1 0 0 0 0 0 0 1 0 0 1 0 0 b = 'roygb' c = 5×6 logical array 1 0 0 0 0 0 1 1 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 1 1 0 0 0 b = 'roygbp' M = 8 I = 2 winner = 'o'

7   Pass
ind = randi(5); switch ind case 1 clear board board(:,:,1) = ['rrbrbbr';'rbrbbrb';'bbrbbrb';'rbrrrbr';'bbrbbbr';'bbbrrbr']; board(:,:,2) = ['brbbbrb';'rrrbbbr';'bbrbrbr';'brbrbrr';'rbrrrbr';'brbbbbr']; assert(isequal(rumis_scorer2(board),'b')) case 2 clear board board(:,:,1) = ['ppbrpbr';'rbrpbrb';'bbrbbrb';'rbrrppr';'bbrpbbr';'bbprrbr']; board(:,:,2) = ['brbpbrb';'rrpbbpr';'pprbrbr';'brprbrr';'rbrrpbr';'brppbbr']; assert(isequal(rumis_scorer2(board),'r')) case 3 clear board board(:,:,1) = ['brbrb';'rrrbb';'bggob';'ggoro';'bbrbr']; board(:,:,2) = ['bobrb';'roggr';'bogor';'bgoor';'rgrrr']; board(:,:,3) = ['bobrg';'rrbgr';'rooor';'brbrg';'rgrrr']; board(:,:,4) = ['borbg';'rrbbr';'bbrbr';'bboog';'rgrog']; board(:,:,5) = ['robbr';'bbror';'borbr';'rrobb';'boobg']; assert(isequal(rumis_scorer2(board),'b')) case 4 clear board board(:,:,1) = ['rrbrryr';'rbrrryb';'brrrbyb';'rbrbyyr';'rbrbryr';'brrrybr']; board(:,:,2) = ['brbybrb';'rbybbbr';'bbrbrbr';'brbryrr';'rbrrbbr';'brbbybr']; board(:,:,3) = ['byyybry';'ybbbyyr';'bbrbyyr';'brbyyrr';'rbyyybr';'brybybr']; assert(isequal(rumis_scorer2(board),'y')) case 5 clear board board(:,:,1) = ['prbrby';'pprbby';'bggoyb';'gpyoro';'bppbyr']; board(:,:,2) = ['pobrby';'rogygr';'bogoyr';'bgyoor';'rgyyyr']; board(:,:,3) = ['ppbrgy';'rpybgr';'roooyr';'brybrg';'rgryrr']; board(:,:,4) = ['borbgy';'rpbybr';'bbrbry';'bbyoog';'rgrpog']; board(:,:,5) = ['robbry';'bprory';'borbry';'rroybb';'booybg']; board(:,:,6) = ['oobyry';'bpryor';'bopbyr';'rooppb';'boobyg']; assert(isequal(rumis_scorer2(board),'o')) end

b = [] c = 6×7 logical array 1 1 0 1 1 0 1 1 0 1 1 1 0 0 0 1 1 1 0 0 0 1 0 1 0 0 0 1 1 0 1 0 1 0 1 0 1 1 1 0 0 1 b = 'r' c = 6×7 logical array 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 b = 'r' c = 6×7 logical array 0 0 0 0 0 1 0 0 0 0 0 0 1 0 0 0 0 0 0 1 0 0 0 0 0 1 1 0 0 0 0 0 0 1 0 0 0 0 0 1 0 0 b = 'ry' c = 6×7 logical array 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 b = 'ry' c = 6×7 logical array 0 0 1 0 0 0 0 0 1 0 0 0 0 1 1 0 0 0 1 0 1 0 1 0 1 0 0 0 0 1 0 1 0 0 0 1 0 0 0 0 1 0 b = 'ryb' c = 6×7 logical array 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 b = 'ryb' M = 16 I = 2 winner = 'y'

8   Pass
ind = randi(5); switch ind case 1 clear board board(:,:,1) = ['rrbrbbr';'rbrbbrb';'bbrbbrb';'rbrrrbr';'bbrbbbr';'bbbrrbr']; board(:,:,2) = ['brbbbrb';'rrrbbbr';'bbrbrbr';'brbrbrr';'rbrrrbr';'brbbbbr']; assert(isequal(rumis_scorer2(board),'b')) case 2 clear board board(:,:,1) = ['ppbrpbr';'rbrpbrb';'bbrbbrb';'rbrrppr';'bbrpbbr';'bbprrbr']; board(:,:,2) = ['brbpbrb';'rrpbbpr';'pprbrbr';'brprbrr';'rbrrpbr';'brppbbr']; assert(isequal(rumis_scorer2(board),'r')) case 3 clear board board(:,:,1) = ['brbrb';'rrrbb';'bggob';'ggoro';'bbrbr']; board(:,:,2) = ['bobrb';'roggr';'bogor';'bgoor';'rgrrr']; board(:,:,3) = ['bobrg';'rrbgr';'rooor';'brbrg';'rgrrr']; board(:,:,4) = ['borbg';'rrbbr';'bbrbr';'bboog';'rgrog']; board(:,:,5) = ['robbr';'bbror';'borbr';'rrobb';'boobg']; assert(isequal(rumis_scorer2(board),'b')) case 4 clear board board(:,:,1) = ['rrbrryr';'rbrrryb';'brrrbyb';'rbrbyyr';'rbrbryr';'brrrybr']; board(:,:,2) = ['brbybrb';'rbybbbr';'bbrbrbr';'brbryrr';'rbrrbbr';'brbbybr']; board(:,:,3) = ['byyybry';'ybbbyyr';'bbrbyyr';'brbyyrr';'rbyyybr';'brybybr']; assert(isequal(rumis_scorer2(board),'y')) case 5 clear board board(:,:,1) = ['prbrby';'pprbby';'bggoyb';'gpyoro';'bppbyr']; board(:,:,2) = ['pobrby';'rogygr';'bogoyr';'bgyoor';'rgyyyr']; board(:,:,3) = ['ppbrgy';'rpybgr';'roooyr';'brybrg';'rgryrr']; board(:,:,4) = ['borbgy';'rpbybr';'bbrbry';'bbyoog';'rgrpog']; board(:,:,5) = ['robbry';'bprory';'borbry';'rroybb';'booybg']; board(:,:,6) = ['oobyry';'bpryor';'bopbyr';'rooppb';'boobyg']; assert(isequal(rumis_scorer2(board),'o')) end

b = [] c = 5×5 logical array 0 1 0 1 0 1 1 1 0 0 0 0 0 0 0 0 0 0 1 0 0 0 1 0 1 b = 'r' c = 5×5 logical array 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 1 0 1 0 0 0 0 0 b = 'ro' c = 5×5 logical array 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 b = 'ro' c = 5×5 logical array 0 0 0 0 0 0 0 0 0 0 0 1 1 0 0 1 1 0 0 0 0 0 0 0 0 b = 'rog' c = 5×5 logical array 1 0 1 0 1 0 0 0 1 1 1 0 0 0 1 0 0 0 0 0 1 1 0 1 0 b = 'rogb' c = 5×5 logical array 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 b = 'rogb' M = 10 I = 4 winner = 'b'