The three rules of Ruby Q.:
Please do not post any solutions or spoiler discussion for this quiz
48 hours have passed from the time on this message.
Support Ruby Q. by submitting ideas as often as you can:
Suggestion: A [QUIZ] in the subject of emails about the problem helps
on Ruby T. follow the discussion. Please reply to the original quiz
if you can.
The majority of the strategy in Blackjack hinges around the dealer’s
reasons are likely obvious to most of you: that’s the hand you have to
the dealer plays by fixed rules we can predict.
For those unfamiliar with Blackjack, you only need to know a tiny bit
game for the purposes of this exercise. The goal for both the player
dealer is to draw cards to make a hand with the highest total possible,
going over 21. Going over 21 is called “busting” and it means you lose
hand. Face cards count for ten, aces are one or eleven (whichever is
the hand), and all other cards count for their face value. You start
cards and, if they happen to be a ten valued card and an ace (a count of
the hand is called a “natural.” A natural is an automatic win in most
The dealer begins with one of his two cards face up and one face down.
the former the “upcard.” The dealer will “hit” or take more cards until
reaches a count of 17 or higher. After that he will “stand” or leave
where it is. That tells us that there are only seven possible outcomes
dealer: get dealt a natural, bust, or hit to a total of 17, 18, 19, 20,
We start every hand knowing half of what the dealer holds thanks to the
Believe it or not, you can make pretty reliable guesses about how the
go with just that knowledge.
Write a Ruby program that shows the percent chance of a dealer reaching
possible outcome based on the upcard showing.
I’ll give you some hints to verify your results. Basic Blackjack
teaches that we should assume the dealer “has a ten in the hole” (as the
down card). It’s not always true, of course, but 17 is a common outcome
dealer with an upcard of seven. Finally, we call five and six “the
bust cards” for reasons that will become obvious if you are outputting
In the casinos Blackjack is often played with more than one deck
together. One, two, six, and eight deck games are common. You may want
offer the option to adjust the deck size your program uses. Either way,
default to two decks as an average of what a player will face.