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,681 of 57,431   
   Tim Rentsch to Dmitry A. Kazakov   
   Re: A little puzzle.   
   25 Nov 22 06:26:53   
   
   From: tr.17687@z991.linuxsc.com   
      
   "Dmitry A. Kazakov"  writes:   
      
   > On 2022-11-25 10:16, Tim Rentsch wrote:   
   >   
   >> "Dmitry A. Kazakov"  writes:   
   >>   
   >>> On 2022-11-24 23:51, Tim Rentsch wrote:   
   >>>   
   >>>> For the general case we would like to handle any circular measure   
   >>>> (for convenience having coordinates in some integer range).   
   >>>   
   >>> [...]   
   >>>   
   >>>> Exercise: write a function to answer this kind of question for   
   >>>> circular measures in general.  You may assume integer coordinates   
   >>>> and intervals that include the starting point but do not include   
   >>>> the end point.  Give a suitable declaration for the function,   
   >>>> and separately give a function definition to implement the given   
   >>>> interface.   
   >>>   
   >>> Usual technique is expanding the range this or that way.  E.g.   
   >>>   
   >>> - Computing differences in the specified direction and complementing   
   >>> by the modulo when the difference turns negative.   
   >>> - Using large non-modular numbers that never overflow, e.g. with   
   >>> indices of a ring buffer.  A 64-bit sequence number I is the new   
   >>> "index."  To access elements I mod N is used.   
   >>   
   >> Even Edsgar Dijkstra wrote code to show solutions to   
   >> programming exercises.  Where is your code?   
   >   
   > If you ask for code rather than for an algorithm, you must formalize   
   > you question, by providing written specifications in the programming   
   > language of choice.  E.g. specify the ADT longtitude and the operations   
   > you want to implement on it, e.g. range comparisons.   
      
   Apparently you don't realize that part of the problem is to   
   define the interface, not just implement it.  For the programming   
   language, pick any common, widely used language, as for example   
   Ada or C.  For the type of the values involved, pick any standard   
   integer data type that covers a large range of possible values,   
   such as 'intmax_t' in C.  "Give a suitable declaration for the   
   function" means both (a) supplying an appropriate prototype   
   (using C terminology), and (b) either writing a comment or   
   choosing adequately descriptive parameters names for whatever   
   argument values are needed.  "Give a function definition to   
   implement the given interface" means supplying a complete   
   function definition that is compatible with the previously   
   supplied declaration, and that computes the desired result.   
      
   Now once again, where is your code?   
      
   --- 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