Problem 329. Poker Series 01: isStraightFlush
Solution Stats
Problem Comments

8 Comments
define "higher up", is row 1 higher or lower than row 4?
Don't test with with 2 or more straight flushes with different rankings.
@Jean,
Huh? Is that a suggestion to add a test?
Yes, as for example test 8 in problem 333 : Poker Series 02: isQuads.
It is better to modify the last test case as hm = [0 0 0 0 0 0 0 0 1 1 0 1 1;
1 1 0 0 0 0 0 0 0 1 1 1 1;
1 0 0 0 0 0 0 0 0 1 1 1 1;
0 0 0 0 0 0 0 0 0 0 0 0 0];
y_correct.flag = true;
y_correct.usedCards = logical([0 0 0 0 0 0 0 0 0 0 0 0 0;
1 0 0 0 0 0 0 0 0 1 1 1 1;
0 0 0 0 0 0 0 0 0 0 0 0 0;
0 0 0 0 0 0 0 0 0 0 0 0 0]), where I have interchanged the 2nd and 3rd rows of hm. The reason to make this change is that some solutions which simply check whether the row sum equals 5 are indeed incorrect.
Very late here since the last comment, but if you care to update, my code passed all the tests but it ran into an error when dealing with a normal flush. May want to put a test in there for five 1's in a single row but not consecutive
So, just to clarify, because in normal poker, 9 10 J Q K beats A 2 3 4 5, at least I think and an online simulator proved that to be correct...
in your case, A high beats K high? I might need to analyze the expected answers a bit but you did say in your problem statement that A high trumps, so I just wanted to check
If you are starting the Poker Series, consider including a score for the hand in your code. Problems 19 will allow you to identify the hand types (flush, straight, quads, etc.) in problem 10, but in problem 11 you will need a way to break ties between two straights, two full houses, two flushes, etc. For this problem, for example, the score could simply be the high card of the straight flush.
Solution Comments
Show commentsProblem Recent Solvers121
Suggested Problems

Create a function handle that reverses the input arguments of another function handle
147 Solvers

First nonzero element in each column
841 Solvers

355 Solvers

Get the elements of diagonal and antidiagonal for any mbyn matrix
471 Solvers

Side of an equilateral triangle
5980 Solvers
More from this Author51
Problem Tags
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!