Black Jack input and output

4 views (last 30 days)
samantha on 7 Dec 2022
Commented: Arif Hoq on 8 Dec 2022
Hello, I am writing a function called check_possibilities.m where it takes as input the vector possibilities, and returns as output either I get stuck on the largest element of possibilities which is greater than or equal to 17, and less than or equal to 21.
Walter Roberson
Walter Roberson on 7 Dec 2022
Suppose that the vector of possibilities is [7 17] . Should it say "Oh, at least one value is in the range 17 to 21, so hold" ? Or should it say "Oh, at least one value is not in that range, so ask for another card" ?
If the current values were [11 21] you would certainly want to hold, but at [7 17] you might want to take another card in hopes of getting higher than 17 without going bust.

Sign in to comment.

Answers (1)

Arif Hoq
Arif Hoq on 7 Dec 2022
try this:
a=[9 13];
output_1 = -999
b=[23 34];
output_2 = 999
c=[9 20 19 22];
output_3 = 20
function y = check_possibilities(Arg1)
if min(Arg1) > 21
if min(Arg1) < 21
if max(Arg1(Arg1>=17 & Arg1<=21)) >=17 & max(Arg1(Arg1>=17 & Arg1<=21))<=21
y=max(Arg1(Arg1>=17 & Arg1<=21));
  1 Comment
Arif Hoq
Arif Hoq on 8 Dec 2022
did you check my function ?

Sign in to comment.


Find more on Card games in Help Center and File Exchange

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!