4
3
This is kept fairly original:
Write a program that creates a standard blackjack game:
- input "h" means hit or draw another card
input "s" means stand, or take what you have already
Rules:
cards values are as follows:
2-9 = face value of card
10, J, Q, K = 10
aces = 11 unless player busts, then it's only a 1
if 2 or more aces are drawn the first is 11, and each one after is a 1
the bank needs 18-21, and has to draw another card until they are in this range
this game runs forever
Procedure:
- The player gets 2 cards at the beginning, shown by "Player:" in the console (Example: Player gets 2 and 5 at the beginning. Console output: "Player: 2, 5").
- The cards can be shown in the console by their values (For example: 2, 10, 1 | No need for: 2, K, A), but you can also use the card-names instead. Your choice
- The input by the player is "h" for "hit" and "s" for "stand". Also allowed is 1 and 0
- The bank gets one card at the beginning, shown by "Bank:"
- At the end you get the output "Win", "Lose", "Draw", or "Blackjack", depending on the game
This game is a code-golf challenge.
7>
1
for hit0
for stand) as it'll cut down on boiler-plate code, I'd suggest allowing for this lax input (but it's up to you, of course). [Note: do update the post with any clarifications regarding these queries rather than just answering here in comments :)]...in fact also, 2.a. May our program exit after one hand? – Jonathan Allan – 2019-12-16T10:54:21.470
8
Pretty complex challenge, it could benefit of some time in Sandbox for Proposed Challenges.
– manatwork – 2019-12-16T10:55:04.1875
I also recommend the sandbox. To get you started there, you need to explain what constitutes Win/Lose/Draw/Blackjack. and what exactly happens after the user answers.
– Adám – 2019-12-16T10:56:41.6679Oh, and don't forget to state what hitting and standing means. Challenges should be self-contained, and not rely external resources. – Adám – 2019-12-16T10:58:01.290
1
I think this should be tagged as
– Arnauld – 2019-12-16T11:13:00.957interactive
.