OpenBook
  • Problems
  • Tracks
  • How it works
  • Pricing
Start practicingSign In
Problems/CRUD & REST

23. Library Fines Off by a Day

Medium

A library fines module charges members who return books on time. Fix it, then add a grace period, a per-loan fine cap and audited fine waivers.

45 minute budget0.0% acceptancedebugging · date math · audit trail

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. 1Stop charging on-time returns
  2. 2Grace period
  3. 3Fine cap and accrued fines
  4. 4Waivers with an audit trail

Part 1: Stop charging on-time returns

  1. 01Members report being charged a late fee when they return a book on its due date, and late returns seem to cost a day more than they should.
  2. 02A book is on time any time on its due date. Each whole calendar day after the due date costs the loan's daily rate. The library runs on UTC.
  3. 03The due date itself is computed correctly today (the checkout's calendar day plus the loan length). Do not change it.

What the hidden tests check in Part 1

  • The last millisecond of the due date is on time; midnight after it is one day late.
  • Lateness across a year end and across a leap day counts calendar days.
  • A member's balance counts only late returns, each at its own loan's rate.
  • Returns are validated: unknown loans, double returns and returns before checkout throw.

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.