#C14086. Library Book Collection Management

    ID: 43696 Type: Default 1000ms 256MiB

Library Book Collection Management

Library Book Collection Management

You are given an initially empty collection of books. Each book has the following attributes:

  • title (a string)
  • author (a string)
  • publication_year (an integer, represented as a string in the data)
  • genre (a string)
  • isbn (a string)

You will be given a sequence of commands. Process each command and perform the corresponding operation on the collection. The commands are as follows:

  • ADD: Adds a new book. Format: ADD <title> <author> <publication_year> <genre> <isbn>. All fields are single words (i.e. they do not contain spaces).
  • REMOVE: Removes a book by ISBN. Format: REMOVE <isbn>. If the ISBN is not found, ignore the command.
  • SEARCH: Searches for books where the given field (either title, author, or genre) contains the given query as a substring (case-insensitive). Format: SEARCH <field> <query>. Print the matching books.
  • FILTER: Filters the books whose publication year is in the inclusive range. Format: FILTER <start_year> <end_year>. Print the matching books.
  • SORT: Sorts the books by the given field in the specified order. Format: SORT <by> <order>, where by is either title or publication_year and order is either asc (ascending) or desc (descending). Print the sorted list.
  • DISPLAY: Displays all books in the current collection in a formatted table.

All commands that produce an output (SEARCH, FILTER, SORT, DISPLAY) should print the books in a table with the following format:

{'Title':<30} {'Author':<20} {'Year':<6} {'Genre':<15} {'ISBN':<13}
A line of 90 '=' characters below the header, and then each book printed on a separate line using the same field widths.

The formatted output should be exactly as specified.

Note: The use of LaTeX formatting is allowed for formulas. For example, the year range condition can be written as \( start\_year \leq publication\_year \leq end\_year \).

inputFormat

The first line of input contains an integer \( N \) indicating the number of commands. The following \( N \) lines each contain a single command in one of the formats described above. All inputs are read from standard input (stdin).

outputFormat

For every command that produces an output (SEARCH, FILTER, SORT, DISPLAY), print the corresponding books in a table format as described. All output should be sent to standard output (stdout).

## sample
5
ADD BookOne AuthorA 2001 Fiction 1111111111111
ADD BookTwo AuthorB 2005 Non-Fiction 2222222222222
DISPLAY
REMOVE 1111111111111
DISPLAY
Title                         Author              Year   Genre           ISBN         

========================================================================================== BookOne AuthorA 2001 Fiction 1111111111111 BookTwo AuthorB 2005 Non-Fiction 2222222222222 Title Author Year Genre ISBN

BookTwo AuthorB 2005 Non-Fiction 2222222222222

</p>