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

  1. (*
  2. Problem 12 - Perimeter
  3.  
  4. You are in charge of protecting a set of defenseless homeowners from predators that roam the area by constructing a fence of minimum length that encloses all of the homes.  
  5.  
  6. The prototype for your solution is as follows:
  7.  
  8. typedef struct Node {
  9.     UInt32 nodeNum,
  10.     SInt32 xCoord;
  11.     SInt32 yCoord;
  12. } Node;
  13.  
  14. void Perimeter(
  15.     UInt32 numHomes,
  16.     Node homesToEnclose[],
  17.     UInt32 *numNodesInPerimeter,
  18.     UInt32 nodesInPerimeter[]
  19. );
  20.  
  21. You are given a list homesToEnclose of numHomes homes to protect by constructing a fence around the homes. You should return a list nodesInPerimeter of the numNodesInPerimeter homes to be connected by a fence.  The fence must enclose all of the homes using the minimum amount of fencing material.
  22. *)
  23.  
  24. unit Solution;
  25.  
  26. interface
  27.  
  28. // Do not modify the interface
  29.  
  30.     uses
  31.         Types, Files;
  32.         
  33.     type Node = record
  34.             xCoord: SInt32;
  35.             yCoord: SInt32;
  36.         end;
  37.     type NodeArray = array [0..0] of Node;
  38.     type UInt32Array = array [0..0] of UInt32;
  39.         
  40.     procedure Perimeter( numHomes: UInt32; const homesToEnclose: NodeArray; var numNodesInPerimeter : UInt32; var nodesInPerimeter: UInt32Array);
  41.  
  42. implementation
  43.  
  44. // Fill in your solution and then submit this folder
  45.  
  46. // Team Name: FILL IN YOUR TEAM NAME!
  47.  
  48. end.
  49.