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

1 Comment
Is there a problem with the third test? Looks like a fourth test was being created. I think my solution should pass.

1 Comment
The second part of Test 3 looks incorrect. This problem has two straight flushes on rows 2 & 3. However, the expected solution only shows a straight flush on row 2
hm = [0 0 0 0 0 0 0 0 1 1 0 1 1
1 0 0 0 0 0 0 0 0 1 1 1 1
1 1 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])
assert(isequal(isStraightFlush(hm),y_correct))

1 Comment
This should satisfy the second part.. I think.

2 Comments
This should only satisfy the first part.
">
Problem Recent Solvers117
Suggested Problems

Who knows the last digit of pi?
623 Solvers

723 Solvers

Find nearest prime number less than input number
459 Solvers

Sum the numbers on the main diagonal
536 Solvers

371 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!