r/codinginterview • u/supernoodle155 • Jul 16 '20
Blackjack Pseudocode Question
Hi all!
I have never used pseudo code before so I'm not very sure about how best to tackle this problem.
The challenge is to design a simple algorithm almost the same as blackjack (the varient is that black cards are added to your score whereas red cards are subtracted from it).
The solution is meant to satisfy the following requirements:
• allows a human to play blackjack with a computer • a points based system with 5 rounds
I am meant to then provide suggestions on how to improve the simple algorithm to increase the probability of the computer winning.
I am wondering if anyone could provide me with some insight on how to go about this problem?
3
Upvotes
1
u/OkBeacon Jul 16 '20
You have three things to consider. Deck of cards,Player and the House
So pseudoCode be like
For each round:
Deal hand
draw player
draw house
Play hand
while cards a. Record input b. Deal handle
handle logic here
Top of my head -
Deck will implement method deal() and maintain state of the deck
player1 and house are instance of same class with method, choice(stand/hit), isBusted(), int handStrenghth etc.
For me, pseudoCode is python code without implementation details. Hope it helps!