Cody

Problem 1687. Poker Card Deal!

Solution 1212292

Submitted on 14 Jun 2017 by Andrew Dobrovolc
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 = 5×5 cell array '5s' '3d' '2h' '8s' '10h' '3d' '2h' '8s' '10h' '8d' '2h' '8s' '10h' '8d' 'qc' '8s' '10h' '8d' 'qc' '2c' '10h' '8d' 'qc' '2c' 'ah' deckLeftover = 1×43 cell array Columns 1 through 22 '10c' '10d' '10s' '2d' '2s' '3c' '3h' '3s' '4c' '4d' '4h' '4s' '5c' '5d' '5h' '6c' '6d' '6h' '6s' '7c' '7d' '7h' Columns 23 through 43 '7s' '8c' '8h' '9c' '9d' '9h' '9s' 'ac' 'ad' 'as' 'jc' 'jd' 'jh' 'js' 'kc' 'kd' 'kh' 'ks' 'qd' 'qh' 'qs' 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))

dealtDeck = 3×5 cell array '6c' '8h' '8s' '10h' '5c' '8h' '8s' '10h' '5c' '5d' '8s' '10h' '5c' '5d' '6s' deckLeftover = 1×45 cell array Columns 1 through 22 '10c' '10d' '10s' '2c' '2d' '2h' '2s' '3c' '3d' '3h' '3s' '4c' '4d' '4h' '4s' '5h' '5s' '6d' '6h' '7c' '7d' '7h' Columns 23 through 44 '7s' '8c' '8d' '9c' '9d' '9h' '9s' 'ac' 'ad' 'ah' 'as' 'jc' 'jd' 'jh' 'js' 'kc' 'kd' 'kh' 'ks' 'qc' 'qd' 'qh' Column 45 'qs' 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))

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

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

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

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