Cody

Problem 1687. Poker Card Deal!

Solution 809312

Submitted on 18 Jan 2016 by goc3
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 = Columns 1 through 12 '9s' '2d' 'qh' '2h' '5h' 'ac' '6h' '5s' '9d' 'js' 'kh' '10s' Columns 13 through 24 '4c' '3h' '7s' 'kd' 'ks' '2c' 'qc' '3d' '8c' 'kc' '4h' '7h' Column 25 'jh' deckLeftover = Columns 1 through 12 '6s' 'qs' 'qd' '5c' '10c' 'ad' '3c' '4d' '8s' 'jc' '8d' 'ah' Columns 13 through 24 '8h' '7c' '10d' '3s' '6d' '5d' '4s' '2s' '6c' 'jd' '9h' 'as' Columns 25 through 27 '9c' '7d' '10h' 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 = Columns 1 through 12 'kh' 'as' 'jd' '6s' 'kc' '10s' 'js' '2h' '5s' '10c' '3s' '8s' Columns 13 through 15 '2c' '2s' '4h' deckLeftover = Columns 1 through 12 '7s' '5c' 'jh' '5d' '10h' 'ks' 'kd' '6d' '8c' '9h' 'qc' '4s' Columns 13 through 24 '6c' '5h' '8h' '2d' 'qd' '7c' 'ac' '3d' '9s' '4c' 'qh' '7h' Columns 25 through 36 'qs' '9c' '7d' '9d' '8d' '3h' 'ah' 'ad' 'jc' '10d' '3c' '4d' Column 37 '6h' 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 = Columns 1 through 12 '7d' '3d' 'qc' '2h' '9h' '6d' '9d' '5s' '7s' 'ac' '8d' '10c' Columns 13 through 24 'jh' 'qh' 'kh' 'ah' '2c' 'jc' '6h' 'js' '9c' '4h' 'kd' '3c' Columns 25 through 28 '6s' '7c' '2d' '6c' deckLeftover = Columns 1 through 12 '5c' 'as' '5h' 'jd' '4c' '10s' '7h' 'kc' '10h' '8c' '4d' '8h' Columns 13 through 24 '3s' '2s' '8s' '9s' '4s' '10d' 'ad' 'qs' 'qd' 'ks' '5d' '3h' 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 = Columns 1 through 12 '4h' 'jh' '4c' 'js' '10s' '6h' '7c' 'ac' '9s' 'jd' 'qc' 'qs' Columns 13 through 24 '5d' 'ks' '3h' '2h' '10c' '8s' '6c' '8d' '6d' '10h' '8c' '8h' Columns 25 through 30 '3d' '2d' '2s' '9h' '3s' '4d' deckLeftover = Columns 1 through 12 '9c' '9d' '10d' '7s' 'kc' 'J' 'ad' '3c' '7d' '5c' 'kd' '2c' Columns 13 through 24 'qd' 'as' 'ah' '6s' '7h' 'J' 'qh' '5h' '5s' '4s' 'jc' 'kh' 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 = 'ac' '8h' '3c' '10h' '5h' 'J' 'jh' '3d' '3h' 'ad' '2d' 'jd' deckLeftover = Columns 1 through 12 '7s' '4d' 'kh' 'qs' '9h' '7h' 'js' 'qd' '2c' '10s' '7c' '8c' Columns 13 through 24 'ks' '9d' '2s' '4h' '6s' '5s' '9s' '8s' 'qh' 'J' '5d' '10c' Columns 25 through 36 'ah' 'kd' '8d' '4c' '4s' '6d' '3s' '9c' 'qc' 'jc' 'as' '6c' Columns 37 through 42 '6h' '2h' '5c' '7d' 'kc' '10d' 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 = 'kc' '3s' '2h' '7h' '5d' 'ac' '8s' '4h' 'ah' deckLeftover = Columns 1 through 12 'js' '6c' '9s' '4s' 'J' '7d' 'qh' '9d' '5h' 'jh' '9c' '10s' Columns 13 through 24 '4c' '9h' 'qs' '4d' '2s' '8h' '6d' '7s' 'kd' '7c' 'jd' 'ks' Columns 25 through 36 '3d' '5c' '10c' 'as' '6h' 'qc' 'ad' '2d' '3c' '8d' '8c' 'qd' Columns 37 through 45 '10d' 'J' 'kh' 'jc' '2c' '10h' '6s' '5s' '3h' 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'

Suggested Problems

More from this Author17

Community Treasure Hunt

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

Start Hunting!