OpenBook
  • Problems
  • Tracks
  • How it works
  • Pricing
Start practicingSign In
Problems/Data Modeling

16. Card Hand Comparator

Medium

A poker-style hand evaluator whose card parser mishandles tens. Fix it, then rank five-card hands, pick the best five from up to seven, and make the ranking configurable.

45 minute budget61.0% acceptanceparsing · sorting · combinatorics

How this problem works

A small TypeScript library with a bug. Part 1: make the failing tests pass without touching tests/. Parts 2 to 4 unlock in order as each part's public tests pass. In a mock interview the product owner asks for a plan before each part, and the grader reads your answer.

  1. 1Fix card parsing so tens are read correctly
  2. 2Compare full hands
  3. 3Partial hands
  4. 4Extensible ranking

Part 1: Fix card parsing so tens are read correctly

  1. 01Any hand that contains a ten (10H, 10S, ...) is rejected with a RangeError.
  2. 02Every other card parses fine, and the rank table itself checks out.
  3. 03Hands are five space-separated cards such as "10H JH QH KH AH".

What the hidden tests check in Part 1

  • A bare rank with no suit ("10", "A") and a lowercase suit ("10h") still throw RangeError.
  • A hand of six cards, or of four, throws RangeError.
  • Two different tens in one hand parse; the same card twice throws RangeError.

Hints for Parts 2 to 4 appear in the workspace as each part unlocks.

Sign in to start

Attempts, files and transcripts are saved to your account so the grader can review how you worked.

Sign inCreate an account
OpenBook

Practice for interviews where you build a feature with an AI assistant.

Early preview. Problems, grading and the interviewer are still changing.

Practice

  • Problems
  • Tracks
  • How it works
  • Pricing

Legal

  • Terms
  • Privacy
© 2026 OpenBook.