Cody

# Problem 1687. Poker Card Deal!

Solution 1627700

Submitted on 14 Sep 2018 by William
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
people = 5; cardsDelt = 5; isJokerIn = 0; [dealtDeck, deckLeftover] = Poker_Deal(people ,cardsDelt ,isJokerIn) deckCheck = {'2h'; '3h'; '4h'; '5h'; '6h'; '7h'; '8h'; '9h'; '10h'; 'jh'; 'qh'; 'kh'; 'ah'; '2d'; '3d'; '4d'; '5d'; '6d'; '7d'; '8d'; '9d'; '10d'; 'jd'; 'qd'; 'kd'; 'ad'; '2s'; '3s'; '4s'; '5s'; '6s'; '7s'; '8s'; '9s'; '10s'; 'js'; 'qs'; 'ks'; 'as'; '2c'; '3c'; '4c'; '5c'; '6c'; '7c'; '8c'; '9c'; '10c'; 'jc'; 'qc'; 'kc'; 'ac'} h = (sum(sum(ismember(deckCheck,dealtDeck))) == 25) & ~issorted(reshape(dealtDeck,25,1)); g = (sum(ismember(deckCheck,deckLeftover)) == (52-25)) & ~issorted(deckLeftover); y_correct = g&h; assert(isequal(g,h))

dealtDeck = 5×5 cell array {0×0 double} {0×0 double} {0×0 double} {0×0 double} {0×0 double} {0×0 double} {0×0 double} {0×0 double} {0×0 double} {0×0 double} {0×0 double} {0×0 double} {0×0 double} {0×0 double} {0×0 double} {0×0 double} {0×0 double} {0×0 double} {0×0 double} {0×0 double} {0×0 double} {0×0 double} {0×0 double} {0×0 double} {0×0 double} dealtDeck = 5×5 cell array {'8c'} {'6c'} {'qc'} {'7s'} {'6h' } {'jd'} {'6s'} {'4h'} {'3c'} {'2c' } {'8h'} {'jc'} {'8s'} {'jh'} {'10h'} {'2s'} {'js'} {'9h'} {'2d'} {'9d' } {'4c'} {'2h'} {'7d'} {'ks'} {'kc' } deckLeftover = 1×27 cell array Columns 1 through 17 {'4s'} {'8d'} {'7c'} {'3s'} {'as'} {'10s'} {'ac'} {'ad'} {'qh'} {'5h'} {'5c'} {'10d'} {'7h'} {'qd'} {'10c'} {'kh'} {'qs'} Columns 18 through 27 {'9c'} {'9s'} {'5d'} {'5s'} {'4d'} {'6d'} {'ah'} {'3d'} {'kd'} {'3h'} deckCheck = 52×1 cell array {'2h' } {'3h' } {'4h' } {'5h' } {'6h' } {'7h' } {'8h' } {'9h' } {'10h'} {'jh' } {'qh' } {'kh' } {'ah' } {'2d' } {'3d' } {'4d' } {'5d' } {'6d' } {'7d' } {'8d' } {'9d' } {'10d'} {'jd' } {'qd' } {'kd' } {'ad' } {'2s' } {'3s' } {'4s' } {'5s' } {'6s' } {'7s' } {'8s' } {'9s' } {'10s'} {'js' } {'qs' } {'ks' } {'as' } {'2c' } {'3c' } {'4c' } {'5c' } {'6c' } {'7c' } {'8c' } {'9c' } {'10c'} {'jc' } {'qc' } {'kc' } {'ac' }

2   Pass
people = 3; cardsDelt = 5; isJokerIn = 0; [dealtDeck, deckLeftover] = Poker_Deal(people ,cardsDelt ,isJokerIn) deckCheck = {'2h'; '3h'; '4h'; '5h'; '6h'; '7h'; '8h'; '9h'; '10h'; 'jh'; 'qh'; 'kh'; 'ah'; '2d'; '3d'; '4d'; '5d'; '6d'; '7d'; '8d'; '9d'; '10d'; 'jd'; 'qd'; 'kd'; 'ad'; '2s'; '3s'; '4s'; '5s'; '6s'; '7s'; '8s'; '9s'; '10s'; 'js'; 'qs'; 'ks'; 'as'; '2c'; '3c'; '4c'; '5c'; '6c'; '7c'; '8c'; '9c'; '10c'; 'jc'; 'qc'; 'kc'; 'ac'} h = (sum(sum(ismember(deckCheck,dealtDeck))) == 15) & ~issorted(reshape(dealtDeck,15,1)); g = (sum(ismember(deckCheck,deckLeftover)) == (52-15)) & ~issorted(deckLeftover); y_correct = g&h; assert(isequal(g,h))

dealtDeck = 3×5 cell array {0×0 double} {0×0 double} {0×0 double} {0×0 double} {0×0 double} {0×0 double} {0×0 double} {0×0 double} {0×0 double} {0×0 double} {0×0 double} {0×0 double} {0×0 double} {0×0 double} {0×0 double} dealtDeck = 3×5 cell array {'qh'} {'9d'} {'ad'} {'3c' } {'6d'} {'5d'} {'jd'} {'9s'} {'10d'} {'ah'} {'7d'} {'2s'} {'3h'} {'6c' } {'8d'} deckLeftover = 1×37 cell array Columns 1 through 18 {'kd'} {'10s'} {'jc'} {'5c'} {'8s'} {'js'} {'kh'} {'qd'} {'7s'} {'jh'} {'4d'} {'6h'} {'kc'} {'5h'} {'4s'} {'2h'} {'3s'} {'as'} Columns 19 through 36 {'7c'} {'2c'} {'qc'} {'5s'} {'4h'} {'10c'} {'8c'} {'4c'} {'2d'} {'ac'} {'9h'} {'8h'} {'7h'} {'6s'} {'9c'} {'10h'} {'ks'} {'qs'} Column 37 {'3d'} deckCheck = 52×1 cell array {'2h' } {'3h' } {'4h' } {'5h' } {'6h' } {'7h' } {'8h' } {'9h' } {'10h'} {'jh' } {'qh' } {'kh' } {'ah' } {'2d' } {'3d' } {'4d' } {'5d' } {'6d' } {'7d' } {'8d' } {'9d' } {'10d'} {'jd' } {'qd' } {'kd' } {'ad' } {'2s' } {'3s' } {'4s' } {'5s' } {'6s' } {'7s' } {'8s' } {'9s' } {'10s'} {'js' } {'qs' } {'ks' } {'as' } {'2c' } {'3c' } {'4c' } {'5c' } {'6c' } {'7c' } {'8c' } {'9c' } {'10c'} {'jc' } {'qc' } {'kc' } {'ac' }

3   Pass
people = 4; cardsDelt = 7; isJokerIn = 0; [dealtDeck, deckLeftover] = Poker_Deal(people ,cardsDelt ,isJokerIn) deckCheck = {'2h'; '3h'; '4h'; '5h'; '6h'; '7h'; '8h'; '9h'; '10h'; 'jh'; 'qh'; 'kh'; 'ah'; '2d'; '3d'; '4d'; '5d'; '6d'; '7d'; '8d'; '9d'; '10d'; 'jd'; 'qd'; 'kd'; 'ad'; '2s'; '3s'; '4s'; '5s'; '6s'; '7s'; '8s'; '9s'; '10s'; 'js'; 'qs'; 'ks'; 'as'; '2c'; '3c'; '4c'; '5c'; '6c'; '7c'; '8c'; '9c'; '10c'; 'jc'; 'qc'; 'kc'; 'ac'} h = (sum(sum(ismember(deckCheck,dealtDeck))) == 28) & ~issorted(reshape(dealtDeck,28,1)); g = (sum(ismember(deckCheck,deckLeftover)) == (52-28)) & ~issorted(deckLeftover); y_correct = g&h; assert(isequal(g,h))

dealtDeck = 4×7 cell array {0×0 double} {0×0 double} {0×0 double} {0×0 double} {0×0 double} {0×0 double} {0×0 double} {0×0 double} {0×0 double} {0×0 double} {0×0 double} {0×0 double} {0×0 double} {0×0 double} {0×0 double} {0×0 double} {0×0 double} {0×0 double} {0×0 double} {0×0 double} {0×0 double} {0×0 double} {0×0 double} {0×0 double} {0×0 double} {0×0 double} {0×0 double} {0×0 double} dealtDeck = 4×7 cell array {'2c'} {'10h'} {'6c'} {'2s'} {'10d'} {'7h'} {'jd' } {'jc'} {'4d' } {'qd'} {'qs'} {'6d' } {'8d'} {'10c'} {'qc'} {'6s' } {'kc'} {'8h'} {'kd' } {'js'} {'3c' } {'5h'} {'ah' } {'7s'} {'5d'} {'3h' } {'2h'} {'ad' } deckLeftover = 1×24 cell array Columns 1 through 18 {'9s'} {'ac'} {'5c'} {'3d'} {'9c'} {'as'} {'3s'} {'qh'} {'10s'} {'4c'} {'6h'} {'ks'} {'7c'} {'jh'} {'5s'} {'8c'} {'7d'} {'4h'} Columns 19 through 24 {'9h'} {'kh'} {'8s'} {'2d'} {'4s'} {'9d'} deckCheck = 52×1 cell array {'2h' } {'3h' } {'4h' } {'5h' } {'6h' } {'7h' } {'8h' } {'9h' } {'10h'} {'jh' } {'qh' } {'kh' } {'ah' } {'2d' } {'3d' } {'4d' } {'5d' } {'6d' } {'7d' } {'8d' } {'9d' } {'10d'} {'jd' } {'qd' } {'kd' } {'ad' } {'2s' } {'3s' } {'4s' } {'5s' } {'6s' } {'7s' } {'8s' } {'9s' } {'10s'} {'js' } {'qs' } {'ks' } {'as' } {'2c' } {'3c' } {'4c' } {'5c' } {'6c' } {'7c' } {'8c' } {'9c' } {'10c'} {'jc' } {'qc' } {'kc' } {'ac' }

4   Pass
people = 5; cardsDelt = 6; isJokerIn = 1; [dealtDeck, deckLeftover] = Poker_Deal(people ,cardsDelt ,isJokerIn) deckCheck = {'2h'; '3h'; '4h'; '5h'; '6h'; '7h'; '8h'; '9h'; '10h'; 'jh'; 'qh'; 'kh'; 'ah'; '2d'; '3d'; '4d'; '5d'; '6d'; '7d'; '8d'; '9d'; '10d'; 'jd'; 'qd'; 'kd'; 'ad'; '2s'; '3s'; '4s'; '5s'; '6s'; '7s'; '8s'; '9s'; '10s'; 'js'; 'qs'; 'ks'; 'as'; '2c'; '3c'; '4c'; '5c'; '6c'; '7c'; '8c'; '9c'; '10c'; 'jc'; 'qc'; 'kc'; 'ac'; 'J'; 'J'} h = (sum(sum(ismember(deckCheck,dealtDeck))) == 30) & ~issorted(reshape(dealtDeck,30,1)); g = (sum(ismember(deckCheck,deckLeftover)) == (54-30)) & ~issorted(deckLeftover); y_correct = g&h; assert(isequal(g,h))

dealtDeck = 5×6 cell array {0×0 double} {0×0 double} {0×0 double} {0×0 double} {0×0 double} {0×0 double} {0×0 double} {0×0 double} {0×0 double} {0×0 double} {0×0 double} {0×0 double} {0×0 double} {0×0 double} {0×0 double} {0×0 double} {0×0 double} {0×0 double} {0×0 double} {0×0 double} {0×0 double} {0×0 double} {0×0 double} {0×0 double} {0×0 double} {0×0 double} {0×0 double} {0×0 double} {0×0 double} {0×0 double} dealtDeck = 5×6 cell array {'10h'} {'5d'} {'ac' } {'5s'} {'8h'} {'7h'} {'3d' } {'9h'} {'ah' } {'9s'} {'qc'} {'8d'} {'5c' } {'J' } {'6c' } {'7c'} {'2c'} {'3c'} {'js' } {'5h'} {'4h' } {'4c'} {'2d'} {'6h'} {'7d' } {'9c'} {'10d'} {'2h'} {'4d'} {'4s'} deckLeftover = 24×1 cell array {'2s' } {'6s' } {'10c'} {'10s'} {'qh' } {'jh' } {'jd' } {'as' } {'6d' } {'kc' } {'J' } {'kh' } {'8s' } {'qd' } {'3h' } {'9d' } {'8c' } {'qs' } {'ad' } {'3s' } {'ks' } {'jc' } {'kd' } {'7s' } deckCheck = 54×1 cell array {'2h' } {'3h' } {'4h' } {'5h' } {'6h' } {'7h' } {'8h' } {'9h' } {'10h'} {'jh' } {'qh' } {'kh' } {'ah' } {'2d' } {'3d' } {'4d' } {'5d' } {'6d' } {'7d' } {'8d' } {'9d' } {'10d'} {'jd' } {'qd' } {'kd' } {'ad' } {'2s' } {'3s' } {'4s' } {'5s' } {'6s' } {'7s' } {'8s' } {'9s' } {'10s'} {'js' } {'qs' } {'ks' } {'as' } {'2c' } {'3c' } {'4c' } {'5c' } {'6c' } {'7c' } {'8c' } {'9c' } {'10c'} {'jc' } {'qc' } {'kc' } {'ac' } {'J' } {'J' }

5   Pass
people = 3; cardsDelt = 4; isJokerIn = 1; [dealtDeck, deckLeftover] = Poker_Deal(people ,cardsDelt ,isJokerIn) deckCheck = {'2h'; '3h'; '4h'; '5h'; '6h'; '7h'; '8h'; '9h'; '10h'; 'jh'; 'qh'; 'kh'; 'ah'; '2d'; '3d'; '4d'; '5d'; '6d'; '7d'; '8d'; '9d'; '10d'; 'jd'; 'qd'; 'kd'; 'ad'; '2s'; '3s'; '4s'; '5s'; '6s'; '7s'; '8s'; '9s'; '10s'; 'js'; 'qs'; 'ks'; 'as'; '2c'; '3c'; '4c'; '5c'; '6c'; '7c'; '8c'; '9c'; '10c'; 'jc'; 'qc'; 'kc'; 'ac'; 'J'; 'J'} h = (sum(sum(ismember(deckCheck,dealtDeck))) == 12) & ~issorted(reshape(dealtDeck,12,1)); g = (sum(ismember(deckCheck,deckLeftover)) == (54-12)) & ~issorted(deckLeftover); y_correct = g&h; assert(isequal(g,h))

dealtDeck = 3×4 cell array {0×0 double} {0×0 double} {0×0 double} {0×0 double} {0×0 double} {0×0 double} {0×0 double} {0×0 double} {0×0 double} {0×0 double} {0×0 double} {0×0 double} dealtDeck = 3×4 cell array {'7s'} {'qd' } {'8h'} {'7c' } {'3h'} {'10c'} {'4s'} {'10d'} {'2c'} {'ah' } {'ac'} {'5h' } deckLeftover = 42×1 cell array {'8c' } {'9s' } {'ad' } {'qh' } {'9c' } {'3d' } {'qc' } {'9d' } {'jh' } {'3s' } {'2h' } {'J' } {'js' } {'ks' } {'kd' } {'qs' } {'8d' } {'4c' } {'10h'} {'4h' } {'7d' } {'6h' } {'8s' } {'10s'} {'3c' } {'7h' } {'5c' } {'6c' } {'4d' } {'6s' } {'6d' } {'kh' } {'as' } {'jc' } {'2s' } {'jd' } {'9h' } {'J' } {'kc' } {'2d' } {'5d' } {'5s' } deckCheck = 54×1 cell array {'2h' } {'3h' } {'4h' } {'5h' } {'6h' } {'7h' } {'8h' } {'9h' } {'10h'} {'jh' } {'qh' } {'kh' } {'ah' } {'2d' } {'3d' } {'4d' } {'5d' } {'6d' } {'7d' } {'8d' } {'9d' } {'10d'} {'jd' } {'qd' } {'kd' } {'ad' } {'2s' } {'3s' } {'4s' } {'5s' } {'6s' } {'7s' } {'8s' } {'9s' } {'10s'} {'js' } {'qs' } {'ks' } {'as' } {'2c' } {'3c' } {'4c' } {'5c' } {'6c' } {'7c' } {'8c' } {'9c' } {'10c'} {'jc' } {'qc' } {'kc' } {'ac' } {'J' } {'J' }

6   Pass
people = 3; cardsDelt = 3; isJokerIn = 1; [dealtDeck, deckLeftover] = Poker_Deal(people ,cardsDelt ,isJokerIn) deckCheck = {'2h'; '3h'; '4h'; '5h'; '6h'; '7h'; '8h'; '9h'; '10h'; 'jh'; 'qh'; 'kh'; 'ah'; '2d'; '3d'; '4d'; '5d'; '6d'; '7d'; '8d'; '9d'; '10d'; 'jd'; 'qd'; 'kd'; 'ad'; '2s'; '3s'; '4s'; '5s'; '6s'; '7s'; '8s'; '9s'; '10s'; 'js'; 'qs'; 'ks'; 'as'; '2c'; '3c'; '4c'; '5c'; '6c'; '7c'; '8c'; '9c'; '10c'; 'jc'; 'qc'; 'kc'; 'ac'; 'J'; 'J'} h = (sum(sum(ismember(deckCheck,dealtDeck))) == 9) & ~issorted(reshape(dealtDeck,9,1)); g = (sum(ismember(deckCheck,deckLeftover)) == (54-9)) & ~issorted(deckLeftover); y_correct = g&h; assert(isequal(g,h))

dealtDeck = 3×3 cell array {0×0 double} {0×0 double} {0×0 double} {0×0 double} {0×0 double} {0×0 double} {0×0 double} {0×0 double} {0×0 double} dealtDeck = 3×3 cell array {'5s'} {'2s'} {'J' } {'jh'} {'9c'} {'2h'} {'qd'} {'ac'} {'as'} deckLeftover = 45×1 cell array {'4c' } {'3h' } {'ks' } {'6c' } {'10h'} {'4d' } {'7d' } {'3s' } {'8c' } {'J' } {'9d' } {'8s' } {'3d' } {'qh' } {'8d' } {'6h' } {'7c' } {'6d' } {'2d' } {'2c' } {'5c' } {'qs' } {'9h' } {'qc' } {'8h' } {'js' } {'kd' } {'9s' } {'ad' } {'6s' } {'7s' } {'7h' } {'kc' } {'5d' } {'10c'} {'kh' } {'10d'} {'ah' } {'jd' } {'3c' } {'10s'} {'4h' } {'4s' } {'5h' } {'jc' } deckCheck = 54×1 cell array {'2h' } {'3h' } {'4h' } {'5h' } {'6h' } {'7h' } {'8h' } {'9h' } {'10h'} {'jh' } {'qh' } {'kh' } {'ah' } {'2d' } {'3d' } {'4d' } {'5d' } {'6d' } {'7d' } {'8d' } {'9d' } {'10d'} {'jd' } {'qd' } {'kd' } {'ad' } {'2s' } {'3s' } {'4s' } {'5s' } {'6s' } {'7s' } {'8s' } {'9s' } {'10s'} {'js' } {'qs' } {'ks' } {'as' } {'2c' } {'3c' } {'4c' } {'5c' } {'6c' } {'7c' } {'8c' } {'9c' } {'10c'} {'jc' } {'qc' } {'kc' } {'ac' } {'J' } {'J' }