Cody

# Problem 3060. Scrabble Scores - 8

Solution 1556515

Submitted on 11 Jun 2018 by cokakola
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]}; mult = [ 'T d T'; ' '; 'd D d'; ' '; 'T d T'; ]; score = [34 34]; assert(isequal(scrabble_scores_8(board,n_pl,order,mult),score))

"itch":[ ] "there":[T d] "apple":[d D ] "poet":[ d] "cat":[ ] 9 27 20 7 5

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]}; mult = [ 'T t t T'; ' '; 'D d d D'; ' '; 'D d d D'; ' '; 'T t t T'; ]; score = [189 54]; assert(isequal(scrabble_scores_8(board,n_pl,order,mult),score))

"stratagems":[T t t T] "matlab":[ ] "there":[ ] "fellow":[D d ] "oar":[ ] "hello":[D d ] "users":[ t ] 171 10 8 26 3 18 7

3   Pass
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]}; mult = [ 'T t T'; ' d d '; ' d d '; ' D t'; 't D '; ' d d '; ' d d '; 'T t T'; ]; score = [43 44 39]; assert(isequal(scrabble_scores_8(board,n_pl,order,mult),score))

"what":[ ] "think":[ ] "this ":[d ] "keen":[ D ] "eel":[ ] "problem":[d ] "loop":[ ] "noob":[ T] "en":[ ] "mo":[ ] "matlab":[ t ] "you":[ d ] "um":[ ] "of":[ ] "do":[ ] 10 12 8 16 3 16 6 24 12 11 5 3

4   Pass
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]}; mult = [ ' T T T '; ' d d'; ' D D '; ' D t d '; ' d'; ' d t '; ' d D D '; ' T T T'; ]; score = [67 140]; assert(isequal(scrabble_scores_8(board,n_pl,order,mult),score)) % 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]}; mult = [ 'Q d T d T d Q'; ' D t D D t D '; ' D q D D q D '; 'd T d T d T d'; ' t D t t D t '; ' q D d d D q '; ' d D d D d '; 'T D D T'; ' D t t t t D '; ' D d d d d D '; 'd T d D d T d'; ' D d d d d D '; ' D t t t t D '; 'T D D T'; ' d D d D d '; ' q D d d D q '; ' t D t t D t '; 'd T d T d T d'; ' D q D D q D '; ' D t D D t D '; 'Q d T d T d Q'; ]; score = [433 188 430 300]; assert(isequal(scrabble_scores_8(board,n_pl,order,mult),score))

"if":[T ] "file":[ D ] "like":[ ] "yue":[T ] "you":[ ] "met":[D t] "it":[ t] "meep":[ d] "please":[ D ] "give":[d t ] "node":[T T] "given":[ T] "like":[d ] "it":[ ] 15 14 8 18 6 18 11 16 18 72 9 2 "philosophy":[ d d d] "generator":[t t t] "convincing":[ t t t] "contact":[D d ] "fortnight":[ D ] "below":[ D ] "responses":[d D q ] "superior":[ d T ] "areas":[ D ] "convention":[ D t ] "overtone":[ d T ] "laboratory":[D t ] "random":[ d ] "travel":[ D t ] "word":[ ] "novelty":[ D q ] "hangover":[ D ] "hunting":[ q D ] "cabal":[Q d ] "al":[ ] "ba":[ ] "ab":[d ] "lo":[ ] "pinch":[ d Q] "heterogeneousness":[ d T d T ] "surface":[ D ] "meerly":[ T ] "em":[ ] "writer":[ d ] "gem":[ T ] "chess":[D t ] "rock":[ ] "concatenate":[ D q D ] "can":[ ] "long":[ d] "flummoxes":[ T d T] "egg":[ Q] "too":[ ] "see":[ ] "eerie":[ q ] "zero":[ ] "zither":[ d Q] "rebel":[ d ] "vet":[ ] "man":[ D ] "woo":[ D ] Columns 1 through 30 29 18 26 24 32 20 30 33 10 34 36 34 11 22 8 32 30 28 53 52 207 24 37 10 18 24 10 72 5 7 Columns 31 through 41 216 20 3 3 8 13 76 8 6 10 12

5   Pass
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]}; mult = [ 'T d T'; ' '; 'd D d'; ' '; 'T d T'; ]; switch ind2 case 2 n_pl = 2; score = [34 34]; case 3 n_pl = 3; score = [16 32 20]; case 4 n_pl = 4; score = [14 27 20 7]; 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]}; mult = [ 'T t t T'; ' '; 'D d d D'; ' '; 'D d d D'; ' '; 'T t t T'; ]; switch ind2 case 2 n_pl = 2; score = [189 54]; case 3 n_pl = 3; score = [204 13 26]; case 4 n_pl = 4; score = [174 28 15 26]; 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]}; mult = [ 'T t T'; ' d d '; ' d d '; ' D t'; 't D '; ' d d '; ' d d '; 'T t T'; ]; switch ind2 case 2 n_pl = 2; score = [44 82]; case 3 n_pl = 3; score = [43 44 39]; case 4 n_pl = 4; score = [25 39 19 43]; 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]}; mult = [ ' T T T '; ' d d'; ' D D '; ' D t d '; ' d'; ' d t '; ' d D D '; ' T T T'; ]; switch ind2 case 2 n_pl = 2; score = [67 140]; case 3 n_pl = 3; score = [116 45 46]; case 4 n_pl = 4; score = [39 104 28 36]; end end assert(isequal(scrabble_scores_8(board,n_pl,order,mult),score))

"what":[ ] "think":[ ] "this ":[d ] "keen":[ D ] "eel":[ ] "problem":[d ] "loop":[ ] "noob":[ T] "en":[ ] "mo":[ ] "matlab":[ t ] "you":[ d ] "um":[ ] "of":[ ] "do":[ ] 10 12 8 16 3 16 6 24 12 11 5 3