home *** CD-ROM | disk | FTP | other *** search
/ MacHack 1998 / MacHack 1998.toast / Programming Contest / Problems Folder / Problem 08 - Packing / Solution.p < prev   
Encoding:
Text File  |  1998-06-03  |  1.2 KB  |  44 lines  |  [TEXT/CWIE]

  1. (*
  2. Problem 08 - Packing
  3.  
  4. PointArray = array[0..0] of Point;
  5. PointArrayPtr = ^PointArray;
  6.  
  7. procedure PackBoxes( frame: Rect; box_count: UInt32; boxes: PointArray; toplefts: PointArrayPtr );
  8.  
  9. Given a frame, and a set of rectangles (represented just by height and width in the boxes array), you must find a way to fit all the rectangles inside the frame without overlapping.  Just like QuickDraw standard rectangles, two adjacent rectangles could have the same right/left coordinate, so that they are touching but not overlapping.  Similarly, rectangles may touch the edge of the frame.  When you find a solution, you should return the topleft coordinates of each rectange.  Rectangles may only be moved horrizontally or vertically, they may not be rotated.
  10.  
  11. Example
  12.  
  13. frame = (10, 10, 100, 100 )
  14. box_count = 3
  15. boxes = { (50, 90), (40, 40), (40, 50) }
  16.  
  17. return
  18.  
  19. toplefts = { (10, 10), (60, 10), (60, 50) }
  20.  
  21. *)
  22.  
  23. unit Solution;
  24.  
  25. interface
  26.  
  27. // Do not modify the interface
  28.  
  29.     uses
  30.         Types, Files;
  31.         
  32.     type
  33.         PointArray = array[0..0] of Point;
  34.         PointArrayPtr = ^PointArray;
  35.     procedure PackBoxes( frame: Rect; box_count: UInt32; boxes: PointArray; toplefts: PointArrayPtr );
  36.  
  37. implementation
  38.  
  39. // Fill in your solution and then submit this folder
  40.  
  41. // Team Name: FILL IN YOUR TEAM NAME!
  42.  
  43. end.
  44.