Cody

# Problem 1687. Poker Card Deal!

Solution 1952288

Submitted on 28 Sep 2019 by Augusto Mazzei
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))

dealt = 5×5 string array "10c" "5c" "as" "ad" "6h" "6d" "7h" "8c" "10h" "3h" "4d" "js" "9h" "5s" "9c" "jc" "9s" "qc" "jh" "2s" "6s" "9d" "4h" "qd" "kc" left = 27×1 string array "2c" "jd" "7s" "ac" "10s" "3s" "2d" "2h" "10d" "4s" "7d" "5d" "8h" "8s" "7c" "qs" "ks" "4c" "3d" "6c" "kd" "qh" "kh" "8d" "ah" "3c" "5h" dealtDeck = 5×5 string array "10c" "5c" "as" "ad" "6h" "6d" "7h" "8c" "10h" "3h" "4d" "js" "9h" "5s" "9c" "jc" "9s" "qc" "jh" "2s" "6s" "9d" "4h" "qd" "kc" deckLeftover = 27×1 string array "2c" "jd" "7s" "ac" "10s" "3s" "2d" "2h" "10d" "4s" "7d" "5d" "8h" "8s" "7c" "qs" "ks" "4c" "3d" "6c" "kd" "qh" "kh" "8d" "ah" "3c" "5h" 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))

dealt = 3×5 string array "jd" "9c" "qs" "ah" "ks" "3s" "3d" "2s" "qh" "5c" "8h" "10h" "2d" "as" "9s" left = 37×1 string array "10d" "7d" "7h" "4d" "4c" "9d" "kh" "js" "ad" "6h" "4h" "5h" "9h" "7c" "qd" "8c" "3h" "10c" "4s" "8d" "10s" "qc" "6s" "kc" "kd" "7s" "ac" "2h" "6d" "5d" "jh" "3c" "5s" "8s" "6c" "jc" "2c" dealtDeck = 3×5 string array "jd" "9c" "qs" "ah" "ks" "3s" "3d" "2s" "qh" "5c" "8h" "10h" "2d" "as" "9s" deckLeftover = 37×1 string array "10d" "7d" "7h" "4d" "4c" "9d" "kh" "js" "ad" "6h" "4h" "5h" "9h" "7c" "qd" "8c" "3h" "10c" "4s" "8d" "10s" "qc" "6s" "kc" "kd" "7s" "ac" "2h" "6d" "5d" "jh" "3c" "5s" "8s" "6c" "jc" "2c" 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))

dealt = 4×7 string array "ks" "7c" "3h" "10d" "kh" "qc" "jd" "jc" "2s" "4h" "qd" "9c" "7d" "5c" "5h" "2d" "5d" "10s" "6d" "10c" "ad" "ac" "9s" "ah" "4d" "9h" "8h" "as" left = 24×1 string array "js" "5s" "4c" "jh" "7s" "kc" "6s" "2h" "3c" "3d" "10h" "8d" "qs" "8s" "7h" "kd" "8c" "6h" "6c" "4s" "qh" "3s" "9d" "2c" dealtDeck = 4×7 string array "ks" "7c" "3h" "10d" "kh" "qc" "jd" "jc" "2s" "4h" "qd" "9c" "7d" "5c" "5h" "2d" "5d" "10s" "6d" "10c" "ad" "ac" "9s" "ah" "4d" "9h" "8h" "as" deckLeftover = 24×1 string array "js" "5s" "4c" "jh" "7s" "kc" "6s" "2h" "3c" "3d" "10h" "8d" "qs" "8s" "7h" "kd" "8c" "6h" "6c" "4s" "qh" "3s" "9d" "2c" 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))

dealt = 5×6 string array "6d" "qd" "kd" "5d" "7h" "J" "5s" "2d" "4d" "ah" "ks" "3s" "3c" "qc" "8c" "jc" "4c" "7s" "kc" "7c" "5h" "8h" "qs" "10s" "2h" "3h" "kh" "6c" "ad" "8d" left = 24×1 string array "jd" "9c" "3d" "7d" "6h" "10d" "2s" "9h" "qh" "J" "4s" "as" "2c" "jh" "js" "5c" "6s" "4h" "9d" "9s" "ac" "10h" "8s" "10c" dealtDeck = 5×6 string array "6d" "qd" "kd" "5d" "7h" "J" "5s" "2d" "4d" "ah" "ks" "3s" "3c" "qc" "8c" "jc" "4c" "7s" "kc" "7c" "5h" "8h" "qs" "10s" "2h" "3h" "kh" "6c" "ad" "8d" deckLeftover = 24×1 string array "jd" "9c" "3d" "7d" "6h" "10d" "2s" "9h" "qh" "J" "4s" "as" "2c" "jh" "js" "5c" "6s" "4h" "9d" "9s" "ac" "10h" "8s" "10c" 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))

dealt = 3×4 string array "9c" "ad" "4h" "ac" "6c" "qd" "kd" "5s" "qh" "10c" "7s" "2d" left = 42×1 string array "8d" "7d" "3c" "5d" "6h" "7c" "10s" "qc" "jh" "ks" "9h" "ah" "jc" "8c" "jd" "4s" "2h" "4d" "6s" "8s" "3h" "J" "J" "qs" "9s" "9d" "3d" "7h" "10d" "js" "5c" "4c" "6d" "as" "5h" "10h" "2c" "kh" "kc" "3s" "2s" "8h" dealtDeck = 3×4 string array "9c" "ad" "4h" "ac" "6c" "qd" "kd" "5s" "qh" "10c" "7s" "2d" deckLeftover = 42×1 string array "8d" "7d" "3c" "5d" "6h" "7c" "10s" "qc" "jh" "ks" "9h" "ah" "jc" "8c" "jd" "4s" "2h" "4d" "6s" "8s" "3h" "J" "J" "qs" "9s" "9d" "3d" "7h" "10d" "js" "5c" "4c" "6d" "as" "5h" "10h" "2c" "kh" "kc" "3s" "2s" "8h" 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))

dealt = 3×3 string array "7d" "as" "5c" "qd" "2h" "qc" "8d" "9d" "8s" left = 45×1 string array "4d" "3s" "5d" "10h" "2d" "jd" "ac" "9c" "10c" "3h" "jc" "6h" "ad" "3c" "7s" "8h" "jh" "kd" "4h" "2s" "J" "10d" "6s" "9h" "qh" "3d" "2c" "qs" "10s" "kh" "5h" "6d" "ah" "9s" "4c" "J" "4s" "8c" "7h" "js" "7c" "kc" "ks" "5s" "6c" dealtDeck = 3×3 string array "7d" "as" "5c" "qd" "2h" "qc" "8d" "9d" "8s" deckLeftover = 45×1 string array "4d" "3s" "5d" "10h" "2d" "jd" "ac" "9c" "10c" "3h" "jc" "6h" "ad" "3c" "7s" "8h" "jh" "kd" "4h" "2s" "J" "10d" "6s" "9h" "qh" "3d" "2c" "qs" "10s" "kh" "5h" "6d" "ah" "9s" "4c" "J" "4s" "8c" "7h" "js" "7c" "kc" "ks" "5s" "6c" 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' }

### Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!