Skip to content

Instantly share code, notes, and snippets.

@mcs
Created May 19, 2022 21:17
Show Gist options
  • Save mcs/986428e554c16e20fcd733d0b73b1aec to your computer and use it in GitHub Desktop.
Save mcs/986428e554c16e20fcd733d0b73b1aec to your computer and use it in GitHub Desktop.
public boolean test(List<Card> cards) {
if (cards == null || isStraightFlush.test(cards)) {
return false;
}
Map<Suit, Integer> sortedCards = cards.stream()
.map(Card::suit)
.collect(Collectors.toMap(Function.identity(), s -> 1, Integer::sum));
return sortedCards.values().stream()
.anyMatch(count -> count >= 5);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment