Cody

# Problem 1687. Poker Card Deal!

Solution 1883024

Submitted on 24 Jul 2019 by David Hill
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 string array "qs" "4c" "qh" "5h" "ac" "ks" "9h" "3h" "7s" "10h" "9c" "10d" "6s" "2c" "ah" "qd" "10c" "kd" "8c" "8h" "7h" "jh" "6h" "5c" "2h" deckLeftover = 27×1 string array "3d" "6d" "js" "8s" "2s" "as" "2d" "7d" "4d" "5s" "3c" "7c" "8d" "4h" "4s" "jd" "9d" "qc" "10s" "6c" "ad" "jc" "5d" "3s" "kc" "kh" "9s" 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 string array "js" "9d" "qc" "4s" "as" "4d" "5d" "2s" "jh" "8h" "7s" "10s" "3h" "2c" "qh" deckLeftover = 37×1 string array "7c" "jd" "2d" "5h" "ah" "4h" "5c" "4c" "ad" "3c" "10h" "kd" "2h" "qs" "jc" "ac" "7d" "9c" "7h" "kc" "9s" "qd" "6d" "5s" "6s" "10c" "3s" "3d" "ks" "6c" "9h" "10d" "kh" "8d" "8s" "8c" "6h" 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 string array "6d" "6s" "10d" "4c" "jc" "3c" "4d" "7s" "8h" "3s" "5s" "10c" "7c" "5d" "jd" "4h" "6h" "qc" "ac" "as" "5c" "2d" "7h" "3h" "10s" "js" "kd" "kh" deckLeftover = 24×1 string array "10h" "ad" "jh" "9h" "7d" "8c" "6c" "2c" "9s" "ks" "8d" "ah" "2h" "2s" "8s" "4s" "kc" "qd" "qh" "3d" "9d" "5h" "qs" "9c" 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 string array "4s" "3s" "as" "3d" "8s" "7h" "kc" "6s" "jd" "5h" "10c" "7s" "3c" "4c" "ks" "2h" "9c" "9h" "8d" "jh" "2s" "kd" "ac" "jc" "7d" "10h" "5c" "9s" "6d" "2d" deckLeftover = 24×1 string array "kh" "5s" "9d" "6c" "8c" "6h" "8h" "qh" "ah" "3h" "qd" "ad" "2c" "7c" "10d" "J" "10s" "js" "4d" "qs" "qc" "5d" "J" "4h" 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 string array "6s" "as" "10c" "10h" "7s" "js" "5c" "2h" "2c" "8c" "7h" "5s" deckLeftover = 42×1 string array "3c" "6c" "5h" "8h" "4s" "3d" "jc" "9d" "qd" "6d" "7d" "9s" "jd" "9c" "7c" "J" "4d" "9h" "5d" "3s" "ah" "J" "qh" "10s" "kd" "kh" "6h" "qs" "10d" "ks" "4c" "8d" "qc" "ad" "8s" "2s" "3h" "ac" "4h" "jh" "kc" "2d" 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 string array "3c" "7s" "5s" "J" "6d" "4s" "qd" "2d" "5c" deckLeftover = 45×1 string array "2h" "6c" "qc" "10s" "as" "3h" "qs" "6s" "8s" "5h" "7d" "10d" "jc" "ks" "10c" "9d" "7c" "8d" "5d" "4c" "ah" "3d" "9s" "2c" "10h" "8h" "9h" "6h" "J" "kc" "8c" "4d" "9c" "js" "2s" "kh" "3s" "kd" "ad" "7h" "qh" "jh" "4h" "jd" "ac" 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' }