Cody

Solution 608349

Submitted on 30 Mar 2015
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
%% board = [ ' cat '; ' i p '; ' t poet'; ' c l '; 'there '; ]; n_pl = 2; order = cell(1,5); order(1) = {[2,2; 5,2]}; order(2) = {[5,1; 5,5]}; order(3) = {[1,5; 5,5]}; order(4) = {[3,5; 3,8]}; order(5) = {[1,4; 1,6]}; score = [23 14]; assert(isequal(scrabble_scores_7(board,n_pl,order),score))

score = 0 0 score = 9 0 score = 9 8 score = 18 8 score = 18 14 score = 23 14

2   Pass
%% board = [ 'stratagems'; ' h a '; 'hello t '; ' r l '; 'fellow a '; ' a b '; ' users '; ]; n_pl = 2; order = cell(1,7); order(1) = {[1,1; 1,10]}; order(2) = {[1,9; 6,9]}; order(3) = {[1,2; 5,2]}; order(4) = {[5,1; 5,6]}; order(5) = {[5,5; 7,5]}; order(6) = {[3,1; 3,5]}; order(7) = {[7,2; 7,6]}; score = [29 30]; assert(isequal(scrabble_scores_7(board,n_pl,order),score))

score = 0 0 score = 13 0 score = 13 10 score = 21 10 score = 21 22 score = 24 22 score = 24 30 score = 29 30

3   Fail
%% board = [ ' what y '; ' h do '; ' this um'; ' l n a'; ' of keen t'; ' o e l'; ' problem a'; ' noob'; ]; n_pl = 3; order = cell(1,12); order(1) = {[1,2; 1,5]}; order(2) = {[1,5; 5,5]}; order(3) = {[3,3; 3,7]}; order(4) = {[5,5; 5,8]}; order(5) = {[5,6; 7,6]}; order(6) = {[7,2; 7,8]}; order(7) = {[4,2; 7,2]}; m_words(:,:,1) = [8,7; 8,10]; m_words(:,:,2) = [7,7; 8,7]; m_words(:,:,3) = [7,8; 8,8]; order(8) = {m_words}; order(9) = {[3,10; 8,10]}; clear m_words m_words(:,:,1) = [1,9; 3,9]; m_words(:,:,2) = [3,9; 3,10]; order(10) = {m_words}; order(11) = {[5,2; 5,3]}; order(12) = {[2,8; 2,9]}; score = [34 32 33]; assert(isequal(scrabble_scores_7(board,n_pl,order),score))

Error: Subscript indices must either be real positive integers or logicals.

4   Fail
%% board = [ ' if you '; ' i u '; ' like '; ' met g '; ' e it l'; ' e v i'; ' please k'; ' node'; ]; n_pl = 2; order = cell(1,12); order(1) = {[1,2; 1,3]}; order(2) = {[1,3; 4,3]}; order(3) = {[3,3; 3,6]}; order(4) = {[1,6; 3,6]}; order(5) = {[1,6; 1,8]}; m_words(:,:,1) = [4,2; 4,4]; m_words(:,:,2) = [3,4; 4,4]; order(6) = {m_words}; order(7) = {[4,2; 7,2]}; order(8) = {[7,2; 7,7]}; order(9) = {[4,7; 7,7]}; m_words(:,:,1) = [8,7; 8,10]; m_words(:,:,2) = [4,7; 8,7]; order(10) = {m_words}; order(11) = {[5,10; 8,10]}; order(12) = {[5,7; 5,8]}; score = [43 44]; assert(isequal(scrabble_scores_7(board,n_pl,order),score))

Error: Assertion failed.

5   Fail
%% board = [ 'c flummoxes zither'; 'al o e e e'; 'ba hunting eerie b'; 'ab a g e o e'; 'lo n m g l'; ' r g responses '; 'random n u u '; ' t v c below p r '; 'convention r e f '; ' r r n a areas'; ' y v c t i c '; ' o philosophy o em'; 'travel n n r r e'; ' e c t e'; ' word i a writer'; ' t n c o l'; 'p fortnight rock y'; 'i n h '; 'novelty m concatenate'; 'c e o a a s g'; 'heterogeneousness g'; ]; n_pl = 4; order = cell(1,41); order(1) = {[12,7; 12,16]}; order(2) = {[5,13; 13,13]}; order(3) = {[8,9; 17,9]}; order(4) = {[11,11; 17,11]}; order(5) = {[17,3; 17,11]}; order(6) = {[8,12; 8,16]}; order(7) = {[6,12; 6,20]}; order(8) = {[6,18; 13,18]}; order(9) = {[10,17; 10,21]}; order(10) = {[9,1; 9,10]}; order(11) = {[12,4; 19,4]}; order(12) = {[2,2; 11,2]}; order(13) = {[7,1; 7,6]}; order(14) = {[13,1; 13,6]}; order(15) = {[15,2; 15,5]}; order(16) = {[19,1; 19,7]}; order(17) = {[3,5; 10,5]}; order(18) = {[3,5; 3,11]}; m_words(:,:,1) = [1,1; 5,1]; m_words(:,:,2) = [2,1; 2,2]; m_words(:,:,3) = [3,1; 3,2]; m_words(:,:,4) = [4,1; 4,2]; m_words(:,:,5) = [5,1; 5,2]; order(19) = {m_words}; order(20) = {[17,1; 21,1]}; order(21) = {[21,1; 21,17]}; order(22) = {[6,20; 12,20]}; clear m_words m_words(:,:,1) = [12,21; 17,21]; m_words(:,:,2) = [12,20; 12,21]; order(23) = {m_words}; order(24) = {[15,16; 15,21]}; order(25) = {[3,11; 5,11]}; order(26) = {[17,17; 21,17]}; order(27) = {[17,15; 17,18]}; order(28) = {[19,11; 19,21]}; order(29) = {[19,14; 21,14]}; order(30) = {[1,7; 4,7]}; order(31) = {[1,6; 1,14]}; order(32) = {[19,21; 21,21]}; order(33) = {[19,6; 21,6]}; order(34) = {[1,14; 3,14]}; order(35) = {[3,14; 3,18]}; order(36) = {[1,16; 4,16]}; order(37) = {[1,16; 1,21]}; order(38) = {[1,21; 5,21]}; order(39) = {[19,3; 21,3]}; order(40) = {[19,9; 21,9]}; order(41) = {[15,16; 17,16]}; score = [127 92 128 108]; assert(isequal(scrabble_scores_7(board,n_pl,order),score))

Error: Assertion failed.

6   Pass
%% anti-cheating test case (random number of players from random board) ind = randi(4); ind2 = randi(3)+1; switch ind case 1 board = [ ' cat '; ' i p '; ' t poet'; ' c l '; 'there '; ]; order = cell(1,5); order(1) = {[2,2; 5,2]}; order(2) = {[5,1; 5,5]}; order(3) = {[1,5; 5,5]}; order(4) = {[3,5; 3,8]}; order(5) = {[1,4; 1,6]}; switch ind2 case 2 n_pl = 2; score = [23 14]; case 3 n_pl = 3; score = [15 13 9]; case 4 n_pl = 4; score = [14 8 9 6]; end case 2 board = [ 'stratagems'; ' h a '; 'hello t '; ' r l '; 'fellow a '; ' a b '; ' users ']; order = cell(1,7); order(1) = {[1,1; 1,10]}; order(2) = {[1,9; 6,9]}; order(3) = {[1,2; 5,2]}; order(4) = {[5,1; 5,6]}; order(5) = {[5,5; 7,5]}; order(6) = {[3,1; 3,5]}; order(7) = {[7,2; 7,6]}; switch ind2 case 2 n_pl = 2; score = [29 30]; case 3 n_pl = 3; score = [30 13 16]; case 4 n_pl = 4; score = [16 18 13 12]; end case 3 board = [ ' what y '; ' h do '; ' this um'; ' l n a'; ' of keen t'; ' o e l'; ' problem a'; ' noob'; ]; order = cell(1,12); order(1) = {[1,2; 1,5]}; order(2) = {[1,5; 5,5]}; order(3) = {[3,3; 3,7]}; order(4) = {[5,5; 5,8]}; order(5) = {[5,6; 7,6]}; order(6) = {[7,2; 7,8]}; order(7) = {[4,2; 7,2]}; m_words(:,:,1) = [8,7; 8,10]; m_words(:,:,2) = [7,7; 8,7]; m_words(:,:,3) = [7,8; 8,8]; order(8) = {m_words}; order(9) = {[3,10; 8,10]}; clear m_words m_words(:,:,1) = [1,9; 3,9]; m_words(:,:,2) = [3,9; 3,10]; order(10) = {m_words}; order(11) = {[5,2; 5,3]}; order(12) = {[2,8; 2,9]}; switch ind2 case 2 n_pl = 2; score = [41 58]; case 3 n_pl = 3; score = [34 32 33]; case 4 n_pl = 4; score = [23 35 18 23]; end case 4 board = [ ' if you '; ' i u '; ' like '; ' met g '; ' e it l'; ' e v i'; ' please k'; ' node'; ]; order = cell(1,12); order(1) = {[1,2; 1,3]}; order(2) = {[1,3; 4,3]}; order(3) = {[3,3; 3,6]}; order(4) = {[1,6; 3,6]}; order(5) = {[1,6; 1,8]}; m_words(:,:,1) = [4,2; 4,4]; m_words(:,:,2) = [3,4; 4,4]; order(6) = {m_words}; order(7) = {[4,2; 7,2]}; order(8) = {[7,2; 7,7]}; order(9) = {[4,7; 7,7]}; m_words(:,:,1) = [8,7; 8,10]; m_words(:,:,2) = [4,7; 8,7]; order(10) = {m_words}; order(11) = {[5,10; 8,10]}; order(12) = {[5,7; 5,8]}; switch ind2 case 2 n_pl = 2; score = [43 44]; case 3 n_pl = 3; score = [33 29 25]; case 4 n_pl = 4; score = [19 28 24 16]; end end assert(isequal(scrabble_scores_7(board,n_pl,order),score))

score = 0 0 0 score = 9 0 0 score = 9 8 0 score = 9 8 9 score = 15 8 9 score = 15 13 9