On the Web Technologies MSc we had a problem in generating an appropriate activity for the course work. We came up with the following:

  • X has a load of books that could be divided into classes (history, web, crime etc)
  • X has a set of three book cases that have shelves that could be moved to accommodate large, medium or small books
  • The total number of shelves is 18 divided between ones able to handle large, medium or small books

The task is to take the XML database defining the books and:

  • Separate them into classes
  • Find the largest book in each class (large, medium or small)
  • Work out the width of shelf needed for each class
  • A class has to fit on a shelf that accommodates the largest book
  • Place all the books on the shelves so that no class is split between two shelves

An algorithm will look something like:

  • Sort out the classes into ones that go on large, medium, or small shelves
  • Fit the class hardest to fit first (usually the largest) and the largest in terms of width first
  • etc

All of this to be accomplished using XSLT transformations. And finally:

Produce an SVG animation of adding the books to the shelves

Here is an example: