Sort the array.
if element[0] == element[4]:
you get here if you have a 5 of a kind.
elIf element [0] == element [2]:
if element[3] == element[4]:
you get here if you have a full house
elif element[0] == element[1]:
if element[2] == element[4]:
you get here if you have a full house
a full hand is a hand that should only have 2 unique cards.
var example_hand = [2, 1, 6, 6, 6]
func is_full_house(hand: Array) -> bool:
var uniques = []
for card in hand:
if not uniques.has(card):
uniques.append(card)
return uniques.size() == 2
You could probably also use the dizzy method which saves 17% compute time
func is_full_house(hand: Array) -> bool:
var dict := {}
for num in hand: dict[num] = 1
return dict.keys().size() == 2