Cody

# Problem 1687. Poker Card Deal!

Solution 1507075

Submitted on 28 Apr 2018 by J. S. Kowontan
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))

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

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

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

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

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))

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

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))

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

### Community Treasure Hunt

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

Start Hunting!