! script to solve waterpipes problem ! LENGTH_GOAL = 5 ! try to achieve this goal READ\-MESSAGES houses.dat X Y ! read in the house positions SCALAR\FIT A B ! declare the free parameters A = 1 ! initialize B = 1 ! initialize D[1:LEN(X)] = LENGTH_GOAL ! DISTANCE = 'ABS(A*X+B-Y)/SQRT(A*A+1)' ! FIT\-MESSAGES D=SQRT(DISTANCE) ! do the fit FIT\UPDATE PIECES ! redo using calculated A and B STATISTICS PIECES PSUM\SUM ! the total length of pipe needed DISPLAY 'Total length of pipe = '//RCHAR(PSUM,'%4.2f')