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,685 of 57,431   
   Dmitry A. Kazakov to Ben Bacarisse   
   Re: A little puzzle.   
   27 Nov 22 11:02:08   
   
   From: mailbox@dmitry-kazakov.de   
      
   On 2022-11-27 03:03, Ben Bacarisse wrote:   
   > Except for some boundary cases 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).   
   >   
   > [The boundary cases of the original problem were that the region was half   
   > open: [start, end) so (in the specific case here)   
   >   
   >    Flight_East_Crosses_Longitude(X, X, X)   
   >   
   > would be FALSE, and for any Y /= X   
   >   
   >    Flight_East_Crosses_Longitude(X, Y, X)   
   >    Flight_East_Crosses_Longitude(X, Y, Y)   
   >   
   > would be TRUE and FALSE respectively.]   
   >   
   >   
   > Tim's description was intended to clarify the problem, but it did not do   
   > so for you.  How, in your opinion, could the question be posed (ideally   
   > in the general form) so that it can be readily understood?   
      
   It depends on the background. E.g.   
      
       implement tests on directed intervals in a ring of modulo K   
      
   Is that readily understood? I don't know. Intervals in a ring are   
   ambiguous. One needs to disambiguate, e.g. by introducing a direction.   
      
   In practical cases rings represent some measurement process gone skewed   
   due to wrapping, like longitude or an RT counter etc. You somehow need   
   to restore the original contiguous value, e.g. when comparing them. It   
   is sometimes impossible to do. I remember a nasty controller designed in   
   a way that the order of messages in its buffer was impossible to restore.   
      
   For example, by using unrolling. Consider interval [I1, I2] in a ring of K.   
      
       if I1 > I2 then   
          I2 := I2 + K; -- Unroll, now I1 <= I2   
       end if;   
      
   here we assume I1 > I2 indicates one single wrap happened. If multiple   
   did, we are lost. (This is how you lose data/get garbage in I/O on data   
   overrun)   
      
   Now the inclusion test must take into account unrolled x:   
      
       x in [I1, I2] or else x + K in [I1, I2]   
      
   Graphically:   
                   K   
       |###    ####| -->      2K   
       |###    #######    ####|   
         |          |   
         x         x+K   
      
   --   
   Regards,   
   Dmitry A. Kazakov   
   http://www.dmitry-kazakov.de   
      
   --- 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