home bbs files messages ]

Forums before death by AOL, social media and spammers... "We can't have nice things"

   comp.programming      Programming issues that transcend langua      57,431 messages   

[   << oldest   |   < older   |   list   |   newer >   |   newest >>   ]

   Message 56,718 of 57,431   
   Tim Rentsch to Ben Bacarisse   
   Re: A little puzzle.   
   01 Dec 22 04:30:45   
   
   From: tr.17687@z991.linuxsc.com   
      
   Ben Bacarisse  writes:   
      
   > "Dmitry A. Kazakov"  writes:   
      
   [...]   
      
   >>    function Flight_East_Crosses_Longitude   
   >>             (  Start, Stop, X : Longtitude   
   >>             )  return Boolean is   
   >>    begin   
   >>       if Start <= Stop then   
   >>          return X in Start..Stop;   
   >>       else   
   >>          return X <= Stop or else X >= Start;   
   >>       end if;   
   >>    end Flight_East_Crosses_Longitude;   
   >   
   > Except for some boundary cases [ie, the region being half open] that   
   > have got lost in the telling, this is similar to Tim's solution.  I   
   > chose to use a recursive call, because I though it explained the   
   > non-trivial case more clearly (but I bet I am pretty much the only   
   > one who thinks that).   
      
   I want to add something here to my earlier comment.  The idea of   
   using a recursive call reflects a deeper understanding of what   
   "circular regions" are.  If one has already assimilated that   
   understanding then I think the recursive call is "more obvious",   
   in the sense that it takes less thought, or I might say less   
   additional thought.  I didn't have that background (and didn't   
   develop it while solving the problem) so for me the cruder but   
   more direct approach was easier to see.  Bottom line, I don't   
   think either formulation is uniformly "easier to understand" than   
   the other;  it depends on one's background (or ability to develop   
   a suitable understanding on the fly, which in this case I did not   
   possess).   
      
   This problem provides an example where it helps to see both   
   approaches to solving the problem, to see how they relate to each   
   other, but also to give an appreciation for the power of having   
   more advanced tools available in the mental toolbox.   
      
   --- SoupGate-Win32 v1.05   
    * Origin: you cannot sedate... all the things you hate (1:229/2)   

[   << oldest   |   < older   |   list   |   newer >   |   newest >>   ]


(c) 1994,  bbs@darkrealms.ca