These are the long rules for the latest POTM. I have tried to be as clear as possible but if there are any questions please ask them as soon as possible so I can correct errors in the weekly FAQ mailings. My goal is to eliminate loopholes - if you have a question about wording, I probably meant the statement to have the simplest possible interpretation. ****** P O W E R S A W ****** (deadline is 11:59 PM EST September 18, 1999) I bought a new power saw. I immediately went to the garage and found a square piece of wood. AHA (thought I), I will try out my saw. I made a perfectly straight cut and two pieces fell to the floor - they had different shapes and sizes since I was quite arbitrary about how my cut was made. I wondered if another cut could give me pieces which all had the same area (I'm weird like that). For the next POTM, YOU can wonder about planning cuts in my wood that will result in pieces with the same area. I'LL draw the line for the first cut, then your program can plan the rest of the cuts. ================== T H E L O N G R U L E S ================= I. YOUR GOAL The goal of your program will be to specify lines to be drawn on a piece of wood measuring 100x100. I will draw the first line, then your program will draw up to ten more lines with the goal of dividing the square into pieces that have equal areas. Your score will be the difference in area between the largest piece and the smallest piece that would be created if I used my powersaw to cut through all the lines. II. INPUT TO YOUR PROGRAM a) if your program executable is called "myprogram", it must read four numbers from the command line as follows: myprogram X1 Y1 X2 Y2 where the four arguments are integers describing two points on the "XY" plane: (X1,Y1) and (X2,Y2). These two points describe the first line (which I get to draw so that it passes through both these points) b) The piece of wood measures Y ^ 100x100 and may be drawn on |----------------+ the XY plane as shown at the | (100,100)| right. | | | * (X1,Y1) | Also shown are examples of two | | points (X1,Y1) and (X2,Y2). | *(X2,Y2) You can imagine a line through | | those two points that would |(0,0) | divide the square into 2 parts. +-----------------> X c) The four values passed to your program on the command line will all be greater than or equal to 0 and less than or equal to 100. They will all be integers. For example, (0,50) (53,50) would describe a horizontal line dividing the area into two identical pieces. These values would be passed to your program as: myprogram 0 50 53 50 d) The initial line (cut) that the POTM-master provides will: 1) meet all rules for valid lines 2) divide the square into two parts III. OUTPUT FROM YOUR PROGRAM a) Your program MUST describe at least one line to draw b) Your program may specify up to TEN lines to draw c) Each line is described by printing four numbers that describe two points through which the line passes. These four numbers X3 Y3 X4 Y4 describe two points on the plane: (X3,Y3) and (X4,Y4) which in turn define the line which passes through the two points on which a cut is to be made. d) Each line is described on a single line of output, so there will be at least one line of output and at most ten lines of output. For example, a valid output describing three lines from your program might be: 5 5 100 100 (diagonal passing through origin) 30 70 100 0 (the other diagonal) 43 0 43 100 (a vertical line) e) As with the input, all values are greater than or equal to zero and less than or equal to 100. They must be integers. f) The four values must describe two distinct points in the square - something like 5 10 5 10 is illegal since the same point is described twice. g) each line your program describes must be different, and must be different from the initial input line. For example, the following is illegal: 5 5 100 100 43 43 62 62 since both sets of points describe the same diagonal. IV. SCORING a) Your fundamental goal is to create a collection of pieces (or polygons) all of which are the same size. To that end, your score will be the size (area) of the largest polygon minus the size (area) of the smallest polygon. The difference will be rounded to the next lowest integer. SCORE1 = INT [Area (largest piece) - Area (smallest piece)] For example, if the largest piece has area 4000.2 and the smallest area is 1000.8, then SCORE1 = INT[4000.2-1000.8] = INT[2999.4] = 2999 Only the largest and smallest pieces will figure in the scoring. If they are all the same size your score will be a perfect ZERO ... the best possible. (in fact, you can score a perfect ZERO with "almost" equal pieces too!) b) Since the starting area is 100 x 100 units, the total area of all the pieces will always be 10,000 square units within the accuracy of the variables. c) The finals will consist of three initial problems provided by the POTM-master, each of which will be started with a different cut. Overall SCORE1 will be the sum of the three individual SCORE1's from the individual problems. d) Lowest overall SCORE1 will win. By definition SCORE1 is an integer and the unrounded values will NOT be considered. e) ONLY in the event of a tie in SCORE1 will the tiebreaker SCORE2 be used. SCORE2 is the total number of pieces (or polygons) that are created by your lines. A HIGH SCORE2 indicating a LOT of pieces is a GOOD score. SCORE2 = total number of pieces (polygons) (high is good) taken over all three final tests f) ONLY in the event of a tie in both SCORE1 and SCORE2, will the winner be judged by execution time. FASTEST program wins. I don't expect it to get this far, but just in case there's a closed form solution of some sort I want to be on the safe side and define a third tiebreaker. Again, times (sys+user) will be summed over all three final runs. ============================================================================= The following items are standard stuff for ALL the POTMs .... (but they occasionally will change ... so READ 'EM!) ============================================================================= I. About your programming: a) As of 9/98 the POTM compiles and executes on and Ultra-2: potm potm 5.5.1 Generic_103640-17 sun4u sparc SUNW,Ultra-2 The Ultra-2 I'm on has 128Mb physical memory and 350Mb virtual memory. It runs Solaris 2.5.1. I must insist that your entry be contained in a SINGLE ASCII file, mailed in plaintext from a mailer that does not split long lines or insert strange characters. Please help keep my life simple!!! b) The compilers I have available are (at least): Sun WorkShop Compiler C 4.2 (ANSI C Compiler SVID compliant) Sun WorkShop Compiler C++ 4.2 GNU compilers gcc/g++ version 2.8.1 *** C/C++ Note: please do not use platform dependent include files *** (like conion.h for example) since they will cause my compilation *** to fail. If YOU need them, consider using ifdefs so that only *** YOUR compilation will see them ... thanks! PERL version 5.004 Java, version 1.1.6 of the Java Developer Toolkit from SUN (as downloaded to a SPARC workstation) FORTRAN compilers from SUN, sorry - no PASCAL support! (rarely used and not encouraged) FORTRAN 90: WorkShop Compilers 4.2 10/22/96 FORTRAN 90 1.2 FORTRAN 77: WorkShop Compilers 4.2 30 Oct 1996 FORTRAN 77 4.2 All compilation will be done WITHOUT ANY OPTIMIZATION, and the standard math library will be loaded (even if not used). While this might not reflect the real world, it is at least consistent. No makefiles are permitted, if there are special instructions please so indicate in your program header comments. *** IMPORTANT: submit early so we can resolve any *** portability problems!!! (Particularly if you *** are working in a PC environment. NOTE: assembly code submissions are NOT acceptable. I must be the one to compile your code so I can check for cheating! c) if you wish to submit a shell program, Bourne, Korn, and csh are available ... along with any bin or /usr/bin tools that are available as generic Unix tools - my judgement!!! Also nawk, awk, dc, or whatever. (again - submit early in case there are version differences) d) Temporary files may be created in /tmp, but MUST be removed when you are done ... creation of files anywhere else is strictly prohibited. e) Maximum size of the source code is roughly 25K characters - different rules may apply for specific POTMS, and comments don't count against you. f) Maximum size of executable is 1 Megabyte ... please!!!! g) sizeof(short)=2; sizeof(int)=4; sizeof(long)=4; sizeof(char)=1 h) a = 0x80000000 = -2147483648 a - 1 = 2147483647 a + 1 = -2147483647 {a} is true. {a == 0} is false. II. The system testing .... a) mail me an entry as soon as possible - you can always submit another entry if you improve your solution .. but try and keep it down to one a week once the porting issues are resolved .... please! b) one entry per person (or team) please. I associate each entry name with an email address and a person for communication purposes. Communication is fine - and encouraged - but everyone's code should be their own unless there is a stated collaboration and a single team entry. Honor system! Use the POTM bulletin board at: http://www.sitepowerup.com/mb/view.asp?BoardID=100152 c) on receipt of your entry, I'll run a system test to make sure your program works ... you'll receive the results and a weekly standing of how you fared against other entries. (I usually will get to new mail once a night but perhaps not!) d) please make sure your program works on the system test problem. e) your program must perform the task specified within the specified time limit (usually ten minutes) sys+user time as measured by timex on MY execution system. Your time will be provided along with your system test run so you can see the differences in speed between your machine and mine. All execution time measurements used for tiebreakers (if any) will be measured using (sys+user) time via timex (similar to time command). **** NOTE: A code fragment to measure elapsed time **** is available from the POTM-master for the asking. III. SENDING ME YOUR ENTRY - PLEASE USE EMAIL!!! Please email (not uuto, no attachments) your source code to me at: enter@att.com (preferred) hicinbothem@att.com (use only as a last resort!) WARNING!!! Please be sure your mailer does NOT truncate long lines or make any substitutions for characters. These kinds of problems will prevent the program from compiling when I receive it! IMPORTANT: Please use the following (or equivalent) lines at the front of the program you mail to me (this will help immeasurably!): /* POTM ENTRY: entryname (something clever please!) */ /* Your Name: First Last */ /* Your email: log@machine.att.com (or whatever) */ /* compile instructions (if other than "make entryname") */ NOTE: These comments should be referenced in whatever method is appropriate for your programming language of choice. IMPORTANT: ENTER EARLY - you will receive weekly standings and you will resolve any portability issues early. You may improve your entry at any time by simply sending me another entry - so it pays to enter earlier! (I process most everything in a day or so) IMPORTANT: If you don't hear from me within a week it may mean that the mail got screwed up .... please follow up with an inquiry to hicinbothem@att.com .... Thanks! If you have any questions, mail 'em to me - if I answer them I'll include them in the Frequently Asked Questions (FAQ) list I circulate with the weekly standings!!! Don't call me ... please! WATCH THE FAQ - ESPECIALLY IN THE FIRST FEW WEEKS AS ALL THE STUPID ERRORS I MAKE IN THE PROBLEM STATEMENT TURN UP!!!! Looking forward to your entry! (remember: enter@att.com) =Fred