All submissions for this problem are available.
Blackjack is a very well known gambling card game played against a
dealer in a casino. In this card game, each player is trying to beat
the dealer, by obtaining a sum of card values not more than 21
which is greater than the sum of dealer card values. Player is initially
given 2 cards, but he could choose to HIT (ask for 3rd card) or STAND
(no more cards). If he chooses to hit for 3rd card and total score
crosses 21 he get busted (loses irrespective of the total score of
dealer cards). Face cards (Jacks, Queens and Kings) are worth 10
points. Aces are worth 1 or 11, whichever is preferable. Other cards
are represented by their number.
Here, you have to implement a conservative player strategy of
playing blackjack. This conservative player does not want to get
busted and hit only when its safe to do so. He follows following
HIT if (score<=11) or (an ACE is held)
Write a program to implement the above strategy given the initial 2
cards of the player.
First line T, will have a single integer having number of test cases followed by T lines of input.
Second Line will have two space seperated inputs (value of first and second card).
and so on..
For each test case, output a single line containing the result.
1) Color of the card does not affects the score of
2) If the value of card is not valid then return INVALID.
3) Don't consider the card with value 10(print INVALID).
4) Input for Face cards must be capital
letters('A','Q','J','K') else return INVALID.
Input 3 J 5 4 3 A F Output: STAND HIT INVALID
1. Here the value of J (JACK) is
10. so the sum of card values is 15, so he
chooses to stand.
2. Here the sum of values of card
4 and 3 is 7. It is less than 11, so it makes
sense for him to draw another card.
3. Here F is an invalid card name.
|Time Limit:||0.1 sec|
|Source Limit:||50000 Bytes|
|Languages:||C, CPP14, JAVA, PYTH, PYTH 3.6, CS2, PAS fpc, PAS gpc, RUBY, PHP, GO, NODEJS, HASK, SCALA, D, PERL, FORT, WSPC, ADA, CAML, ICK, BF, ASM, CLPS, PRLG, ICON, SCM qobi, PIKE, ST, NICE, LUA, BASH, NEM, LISP sbcl, LISP clisp, SCM guile, JS, ERL, TCL, PERL6, TEXT, CLOJ, FS|
Fetching successful submissions