Skip to content

Instantly share code, notes, and snippets.

@jbrechtel
Last active December 11, 2015 23:48
Show Gist options
  • Save jbrechtel/4679274 to your computer and use it in GitHub Desktop.
Save jbrechtel/4679274 to your computer and use it in GitHub Desktop.
Event ticketing problem

You're building a system to process orders for seats to an event

You have two input files

The first is sections.txt. It contains a list of sections of seats. Each section has a name, a number of available seats and a cost per seat. It looks like this

Upper 30 50
Balcony 20 100

Each component is separated by spaces. The first component is the name, the second is the total number of seats in the section and the last is the price per seat in the section. Each section is on a separate line.

The other file is orders.txt. It contains a list of orders. Each order has a customer name, a number of desired seats and a section name. It looks like this

Tom 5 Balcony
Sarah 9 Balcony

Components separated the same as in sections. The first component is the customer's name, the second is the amount of seats the customer wants to buy and the third is the section that the customer wants to buy seats in.

  • Your program should read the two files in and process each order.
  • When an order is processed then the seats sold should be deducted from the remaining seats for that section
  • If a customer wants to purchase more seats than are remaining in a section then the program should not process that order.

When the program is finished the output should be

  • The count of remaining seats in each section
  • The total money earned from sales
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment