FastPrepDetermine the Winner of Three-Card Hands
Problems/Determine the Winner of Three-Card Hands

Determine the Winner of Three-Card Hands

OpenAI logoOpenAI● MediumFULLTIMENEW GRADPHONE SCREEN
QuestionExamples

Problem statement

Source note: An OpenAI phone-screen report described a card game in which each player gets three cards from a dealt stream, the output shows every hand and the winner, a first part ranks three of a kind over a pair over high card, and a second part adds a flush. Later reports confirmed a two-player version with three cards each and a version with two or more players that focused on comparing hands.

A new-grad research candidate, reporting in November 2026, said that the cards are a given input and that a third part assigns each player a betting rule fixed in advance: always bet, bet only with two cards of the same suit, or bet only with two cards of the same rank. That candidate did not finish the third part, so the report says nothing more about it.

Practice choices: the card codes, the dealing order, the rank order, comparing flushes and high cards rank by rank, ties going to the smallest index, the limits and the output rows come from the earlier version of this problem; the betting rule looks only at the first two cards a player received; a player who folds keeps their hand row but cannot win; part 3 compares hands with the part 2 categories; part 3 adds one BET or FOLD row per player, and NO WINNER ends the output when every player folds; the strategies argument is ignored in parts 1 and 2; Examples 4 to 6 are ours.

The judged task matches the reports at about 80%.

Simulate a three-card game for playerCount players numbered from 0 to playerCount - 1. The array dealtCards is the supplied chronological stream of cards to deal. Assign the card at position i to player i % playerCount, starting with player 0. There are exactly three cards per player. Do not shuffle the stream.

The array strategies gives each player's betting rule. It is used only in part 3 and ignored in parts 1 and 2.

The problem statement continues
Pro

Examples

Example 1

dealtCards = ["7C","AH","5C","7D","KD","5D","2S","QC","5S"]playerCount = 3part = 1strategies = ["ALWAYS","ALWAYS","ALWAYS"]return = ["HAND 0 7C 7D 2S","HAND 1 AH KD QC","HAND 2 5C 5D 5S","WINNER 2"]

Player 0 receives positions 0, 3, 6: 7C 7D 2S. Player 1 receives AH KD QC, and player 2 receives 5C 5D 5S. In part 1, player 2's three fives beat player 0's pair of sevens and player 1's ace-high hand. The hand rows retain the cards' receipt order, followed by WINNER 2.

02 · Example 2
FastPrep Pro
Reported in 2 OpenAI interviews this week

Unlock this recently reported problem

FastPrep Pro gives you full access to interview problems reported within the last week.

  • Full problem statement and constraints
  • 5 more worked examples, explained
  • Guided hints and editorial
  • Run your code on real test cases
$8.25/month

$99 billed yearly — or $19 month-to-month. Cancel anytime.

Free plan — 2 of 2 free unlocks used this week
All OpenAI interview questionsSee OpenAI hiring insights
CodePython 3
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
import heapq
from collections import defaultdict
 
class Solution:
def solve(self, values, queries):
# Build the adjacency structure
n = len(values)
graph = defaultdict(list)
for u, v in queries:
graph[u].append(v)
 
best = [float("inf")] * n
heap = [(0, 0)]
while heap:
cost, node = heapq.heappop(heap)
if cost > best[node]:
continue
Run and Submit unlock with Pro
FastPrep Pro
Reported in 2 OpenAI interviews this week

Unlock this recently reported problem

FastPrep Pro gives you full access to interview problems reported within the last week.

  • Full problem statement and constraints
  • 5 more worked examples, explained
  • Guided hints and editorial
  • Run your code on real test cases
$8.25/month

$99 billed yearly — or $19 month-to-month. Cancel anytime.

Free plan — 2 of 2 free unlocks used this week