Gym Member Check-In System
Published 3 October 2026
An Anthropic and Coinbase coding question.
Problem¶
You are building a gym access system that tracks how long each member spends inside the facility. Members can first be registered with:
- A membership ID
- A membership tier
- A monthly fee
Each time a member scans their card, their status toggles:
- If they are currently outside, the scan means they entered the gym.
- If they are currently inside, the scan means they left the gym.
Only completed visits count toward total time. If a member is still inside, their current visit should not yet be included.
Implement:
GymAccessSystem()
addMember(memberId, tier, monthlyFee)
scan(memberId, timestamp)
getTotalTime(memberId)
addMember returns false if the member already exists.
scan returns "invalid_request" if the member does not exist. Otherwise, it records the entry or exit and returns "registered".
getTotalTime returns the total duration of completed visits, or -1 if the member does not exist.
Scan timestamps are guaranteed to arrive in increasing order.
Example¶
Input:
["GymAccessSystem","addMember","scan","scan","getTotalTime"]
[[],["Mia","Standard",50],["Mia",5],["Mia",20],["Mia"]]
Output:
Explanation:
- Mia is successfully added to the system.
- Her first scan at timestamp 5 marks the start of a gym visit.
- Her second scan at timestamp 20 marks the end of that visit, so the completed duration is
20 - 5 = 15. getTotalTime("Mia")therefore returns 15.
If Mia had scanned in but not yet scanned out, that unfinished visit would not be included in her total.