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 commentsGroup

Magic Numbers II
- 14 Problems
- 70 Finishers
- First N Perfect Squares
- Determine if input is a perfect number
- Project Euler: Problem 9, Pythagorean numbers
- Recurring Cycle Length (Inspired by Project Euler Problem 26)
- Project Euler: Problem 9, Pythagorean numbers
- Recurring Cycle Length (Inspired by Project Euler Problem 26)
- Numbers with prime factors 2, 3 and 5.
- Mersenne Primes
- Determine if input is a Narcissistic number
- Determine if input is a perfect number
- Lychrel Number Test (Inspired by Project Euler Problem 55)
- Largest Twin Primes
- Happy 2013...
- Fermat's Last Theorem - Fermat's conjecture
- P-smooth numbers
- Is it an Armstrong number?
- Champernowne Constant
Problem Recent Solvers47
Problem Tags
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!