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,653 of 57,431   
   Ben Bacarisse to David Brown   
   Re: A little puzzle.   
   22 Nov 22 11:40:10   
   
   From: ben.usenet@bsb.me.uk   
      
   David Brown  writes:   
      
   > On 21/11/2022 22:21, Ben Bacarisse wrote:   
   >> David Brown  writes:   
   >>   
   >>> On 21/11/2022 21:45, Ben Bacarisse wrote:   
   >>>> I wonder if there are any real posters here?  Let's see...   
   >>>> I came across a trivial programming task that must have been solved a   
   >>>> thousand times by other programmers, but it had never crossed my path   
   >>>> until yesterday.  I must be feeling my age because I made a real hash of   
   >>>> tackling it at first.  Anyway, I thought it might be of interest.   
   >>>> Consider any ordered measure that "wraps round" -- bearings in degrees,   
   >>>> minutes in the hour, indeed hours in either the 12 or 24 hour clock.   
   >>>> The problem is to determine if a given value is in the sub-range   
   >>>> specified by a start and an en value.   
   >>>> I was specifically concerned with integer values where the sub-range   
   >>>> includes the start value but excludes the end value.   
   >>>> Though I am not sure this merits the term "puzzle", I suggest that   
   >>>> solutions be posted with some spoiler protection.  Do all the news   
   >>>> readers used by programmers (or ex programmers) all respect the presence   
   >>>> of a form-feed character...   
   >>>>    
   >>>> ... like this?  Because that's my favourite way, rather than posting   
   >>>> lots of dummy lines before the solution.   
   >>>>   
   >   
   > Thunderbird seems to respect it when showing the posts.  I am not sure of   
   the most convenient way to add one.  I'll try copy-and-pasting your   
   > FF character...   
   >   
   >>>>    
   >   
   > Did that work?   
      
   Yes, but for my newsreader a form feed only hides what's below it when   
   at the start of a line.   
      
   >>> Are there any restrictions, such as sticking to integers?  The problem   
   >>> becomes quite difficult if your measure is the reals in [0, 1) and   
   >>> your "n" is, say, π/4...   
   >> I don't follow.  What is "my" n?  I did not mention an n.   
   >   
   > You referred to a "start value" and an "en value".   
      
   Sorry, typo.  End value.   
      
   > I like to use names, so I'll call the "start value" "a", and use "n"   
   > for the "en value".  So as far as I understand it, you are asking for   
   > a function that takes an input "x" and determines if there is an   
   > integer "i" such that   
   >   
   > 	x ≡ a + i.n   
   >   
   > where the congruence is over a "wrapping" set.   
      
   Hmm...  I must have made a real hash of the description (and I was being   
   deliberately a bit vague for reasons that should come out later) because   
   there is always such an i.   
      
   Here's an example.  An event starts at 5 minutes to the hour (start =   
   55) and ends at quarter past (end = 15).  The x's 55, 58, 3, 12 and so   
   on are in the range, 53, 17 and 33 are not.   
      
   The fact that all data are integers is not really material.  We could   
   consider compass points in [0, 2*pi) and have arbitrary start and end   
   bearings.   
      
   >> I don't see why the problem can't be naturally extended to a circular   
   >> real interval [0, 1), subject to the fact that we'll use floating point   
   >> numbers for practical purposes.  But I don't think this is what you were   
   >> talking about.   
   >   
   > Well, the point is if "being specifically concerned with integers"   
   > means the puzzle is limited to integer ranges, or if that is just what   
   > you were thinking about first.  I suppose you /do/ mean sticking to   
   > integers, because I'd be surprised if a solution were possible once   
   > you bring arbitrary real numbers into it.  That kind of mathematics   
   > leads to things like the Banach-Tarski paradox, and watching far too   
   > many maths Youtube videos...   
      
   I think I've not explained the problem well because there's not that   
   rarefied about 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