OpenBook
  • Problems
  • Tracks
  • How it works
  • Pricing
Start practicingSign In
Problems/Commerce & Billing

15. Expense Rule Engine

Medium

Fix a corporate-card checker that lets big dinners through, then grow it into per-expense rules, trip limits and nested composite rules.

50 minute budget57.0% acceptancemoney · validation · recursion

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 the amount check so large expenses are flagged
  2. 2Per-expense rules
  3. 3Trip aggregation
  4. 4Composite rules

Part 1: Fix the amount check so large expenses are flagged

  1. 01Finance reports that a 1,200 dollar team dinner sailed past the 500 dollar meal limit without a flag.
  2. 02The same afternoon a 9 dollar coffee was flagged against a 100 dollar limit.
  3. 03Amounts come in exactly as the employee typed them, like "12.50" or "1,200.00".
  4. 04Part 1's public tests reproduce both complaints. Make them pass without breaking the money helpers.

What the hidden tests check in Part 1

  • An expense exactly at the limit is allowed.
  • A single-digit amount is under a two-digit limit.
  • Amounts with thousands separators such as "1,200.00" parse and compare correctly.
  • Negative amounts throw a 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.