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,721 of 57,431   
   Ben Bacarisse to Tim Rentsch   
   Re: A little puzzle.   
   02 Dec 22 00:22:08   
   
   From: ben.usenet@bsb.me.uk   
      
   Tim Rentsch  writes:   
      
   > 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).   
      
   For me, the negated recursive call was a sort of "ah ha!" moment.  I was   
   ploughing forwards trying to work out this and that case when a   
   light-bulb went off.   
      
   Above I say "it explained the non-trivial case more clearly" but that's   
   lazy wording and does not capture what I meant.  Rather than explaining   
   anything, I want code that is easy to verify.  I want, with just a   
   little thought, to know it's right.   
      
   > 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.   
      
   I've got rather fond of it as a question.  I don't conduct any   
   interviews anymore or I would be tempted to use it.   
      
   --   
   Ben.   
      
   --- 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