Cody

# Problem 1687. Poker Card Deal!

Solution 318590

Submitted on 12 Sep 2013 by Matt
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 = '3h' 'qh' '7d' '2s' 'qc' '10c' '7s' '2d' '7c' '2h' '9c' '8d' 'qd' 'kh' 'kc' '6h' 'jc' '5d' '4d' '4h' 'ad' '9s' '5h' '3s' '6d' deckLeftover = '3d' '4s' '5c' '8s' '10h' 'jd' 'qs' 'ah' '4c' '8c' '9h' '10d' 'js' '3c' '6s' '8h' '9d' '10s' 'kd' 'as' '2c' '5s' '6c' '7h' 'jh' 'ks' 'ac' dealtDeck = '3h' 'qh' '7d' '2s' 'qc' '10c' '7s' '2d' '7c' '2h' '9c' '8d' 'qd' 'kh' 'kc' '6h' 'jc' '5d' '4d' '4h' 'ad' '9s' '5h' '3s' '6d' deckLeftover = '3d' '4s' '5c' '8s' '10h' 'jd' 'qs' 'ah' '4c' '8c' '9h' '10d' 'js' '3c' '6s' '8h' '9d' '10s' 'kd' 'as' '2c' '5s' '6c' '7h' 'jh' 'ks' 'ac' 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'

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

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

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

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

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

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

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

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

### Community Treasure Hunt

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

Start Hunting!