Problem 1687. Poker Card Deal!
Anyone want to play a card game?
Well this is making one deck of cards, with the option of using 2 jokers. The outputs are a matrix that represents dealt cards. Rows are the amount of people in play, columns are the amount of cards dealt to each person. The deck that is left over is where the cards were drawn from and is returned as well. That is it! No other things needed.
The cards are named with there face value, such as 2,3,4,5,6,7,8,9,10,j,q,k,a and a joker of only the capital letter J. The suits are s for spades, d for dimonds, h for hearts and c for clubs.
So the final cards look like this:
'js'
'J'
'2h'
'ad'
'5c' and so on.
This function reads in three variables, these are:
people -- This is the amount of people that the cards are being dealt to.
cardsDelt -- This is the amount of cards dealt to each person.
isJokerIn -- This is a true/false (that is 1 or 0), where 1 means 2 jokers (J) are included in play or 0 is no jokers are included in play.
so an example is the following, if the variables are:
%note this example is RANDOM, the outputs must be random to simulate a shuffled deck!!!
people = 5;
cardsDelt = 5; %note, this is a typical deal for a poker game...
isJokerIn = 0;
The outputs will be:
dealtDeck =
'qh' 'as' '5s' '2s' 'jd' 'ad' '5d' '9s' '7h' 'ah' '3c' '2d' 'ac' '8c' 'qd' 'kh' '5h' '4c' '3h' '10s' '6h' '8h' '10c' '4s' '8d'
%note, 5x5, where rows is amount of people and columns are amount of cards dealt...
deckLeftover =
'3s' '4h' '2c' '5c' 'qs' 'jh' 'kd' '2h' '9c' '10h' '9h' '6d' '7c' '7s' '8s' 'qc' 'js' '9d' '7d' 'ks' '6c' '6s' '3d' '10d' 'jc' '4d' 'kc'
Well I hope that everyone has fun with it! Thank you!
Solution Stats
Problem Comments
Solution Comments
Show commentsProblem Recent Solvers47
Suggested Problems
-
Swap the first and last columns
20445 Solvers
-
334 Solvers
-
249 Solvers
-
Find the index of n in magic(n)
243 Solvers
-
There are 10 types of people in the world
1120 Solvers
More from this Author17
Problem Tags
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!