Cody

# Problem 1687. Poker Card Deal!

Solution 274192

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

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

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

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