Skip to content

Instantly share code, notes, and snippets.

View thomaschandler's full-sized avatar

Thomas Chandler thomaschandler

View GitHub Profile

You are a developer and you are getting calls from a bar looking for help. Each night, the bar charges a cover, and in exchange guests are given a series of numbered drink tickets that can be used to exchange for drinks.

The bar staff have been complaining about the difficulty of keeping track of all the tickets during a night, so you have been asked to come up with a solution.

For the bar, you develop a "ticket validation system" that can be used with the terminals located at the bar in order to prevent guests from re-using tickets. This ticket validation window ensures the following:

  1. A ticket with the same number cannot be used twice

  2. A ticket with a value that is too small cannot be used (ex. you took tickets that your friend gave you from another other night and attempt to use them)