/*
* @lc app=leetcode.cn id=2347 lang=typescript
*
* [2347] 最好的扑克手牌
*/
// @lc code=start
function bestHand(ranks: number[], suits: string[]): string {}
// @lc code=end
function bestHand(ranks: number[], suits: string[]): string {
if (suits.every(a => a === suits[0])) return 'Flush'
const set = new Set(ranks)
for (const num of set) {
if (ranks.filter(a => a === num).length >= 3) return 'Three of a Kind'
}
if (set.size < 5) return 'Pair'
return 'High Card'
}
test.each([
{ input: { ranks: [13, 2, 3, 1, 9], suits: ['a', 'a', 'a', 'a', 'a'] }, output: 'Flush' },
{ input: { ranks: [4, 4, 2, 4, 4], suits: ['d', 'a', 'a', 'b', 'c'] }, output: 'Three of a Kind' },
{ input: { ranks: [10, 10, 2, 12, 9], suits: ['a', 'b', 'c', 'a', 'd'] }, output: 'Pair' },
])('input: ranks = $input.ranks, suits = $input.suits', ({ input: { ranks, suits }, output }) => {
expect(bestHand(ranks, suits)).toEqual(output)
})