From: ben.usenet@bsb.me.uk   
      
   Andreas writes:   
      
   > On 24.11.22 14:14, Ben Bacarisse wrote:   
   >> Richard Heathfield writes:   
   >>   
   >>> On 24/11/2022 12:06 am, Ben Bacarisse wrote:   
   >>>> Tim Rentsch writes:   
   >>>>   
   >>>>> I think this problem would make a good interview question,   
   >>>>> provided care were taken to phrase it so the subtleties were   
   >>>>> still there, but possible points of confusion were reduced.   
   >>>>> Not that I know how to do that... :)   
   >>>> I didn't make a good job of presenting it. It certainly didn't pique   
   >>>> anyone else's interest, but then comp.programming is not well populated.   
   >>>> One thing that struck me was that I had not come across this before. I   
   >>>> was surprised that this was not one of those idioms that one absorbs   
   >>>> along the way. I suppose it is of limited use.   
   >>>   
   >>> The trouble is that it comes across as "is y >= x and <= z?", which is   
   >>> about as simple as it gets.   
   >> I am saddened that you think I would have made a hash of that and amazed   
   >> that you could think I had never have come across such a thing   
   >> before. :-(   
   >> I would have thought that   
   >> "Consider any ordered measure that "wraps round" -- bearings in   
   >> degrees, minutes in the hour, indeed hours in either the 12 or 24 hour   
   >> clock."   
   >> might have suggested it was not any old start <= x < end problem. How   
   >> would you have phrased it so as to avoid the confusion?   
   >> Anyway, the take-away is that the size of the range is not part of the   
   >> problem and that no modulo operations are involved. I found that mildly   
   >> interesting.   
   >   
   > This still bothers me. Take your example of 55 minutes being between   
   > 45 minutes and 5 minutes. That's certainly true, but what if the   
   > numbers where not minutes? If your numbers wrapped around at 54   
   > instead of at 60, there wouldn't be a 55. How is your program supposed   
   > to know it? Is it hard coded? Or do you want something flexible enough   
   > to be usable with any "modulo"?   
      
   The data are assumed to be valid -- i.e. in the expected range for the   
   kind of data (0 to 59 for minutes for example).   
      
   And when you need to do this test with potentially invalid data, I'd   
   argue that the correction does not belong here. In some applications it   
   might be appropriate to silently "correct" an invalid datum and in   
   others you might need to hard error.   
      
   The data validation should be somewhere else. That makes the simple   
   test function re-usable.   
      
   I agree that the problem specification should have made that as clear as   
   possible.   
      
   --   
   Ben.   
      
   --- SoupGate-Win32 v1.05   
    * Origin: you cannot sedate... all the things you hate (1:229/2)   
|