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,785 of 57,431   
   Richard Heathfield to Stefan Ram   
   Re: Another little puzzle   
   21 Dec 22 13:09:29   
   
   From: rjh@cpax.org.uk   
      
   On 21/12/2022 12:03 pm, Stefan Ram wrote:   
   > ram@zedat.fu-berlin.de (Stefan Ram) writes:   
   >> Given n times of the 24-hour day, print their average.   
   >> For example, the average of "eight o'clock" and   
   >> "ten o'clock" (n=2) would be "nine o'clock".   
   >> (You can choose any representation, for example "HH:MM"   
   >> or "seconds since midnight".)   
   >   
   >    Thanks for all replies!   
   >   
   >    I waited a few days before answering to allow   
   >    sufficient time to think about the problem.   
   >   
   >    There were not enough tests written and run. As a result,   
   >    the puzzle has not yet been solved (unless I have overlooked   
   >    a contribution or misworded expectations).   
   >   
   >    So, here are two possible test cases.   
   >   
   > average( 23.5,  1.5 )==  0.5   
      
   The specification says "the 24-hour day" --- one day, not two   
   days. So the average of 23.5 and 1.5 is 12.5. 0.5 is a mistake.   
      
   > average( 11.5, 13.5 )== 12.5   
      
   Correct.   
      
   >   
   >    (I use hours as units, so "0.5" means, "half past midnight".)   
   >   
   >    I hope that these test cases encode sensible expectations   
   >    for an average of two times on a 24-hour clock in the spirit   
   >    of the example given in the OP, which was, "the average of   
   >    eight o'clock and ten o'clock would be nine o'clock", since   
   >    these test cases just have rotated that example by 3.5 and   
   >    15.5 hours.   
      
   Your hope is misplaced, because one of your test cases bears an   
   incorrect expected result.   
      
   >   
   >    I believe that I have not seen an algorithm so far in this   
   >    thread that would pass these tests.   
      
   You misunderstood your specification.   
      
   --   
   Richard Heathfield   
   Email: rjh at cpax dot org dot uk   
   "Usenet is a strange place" - dmr 29 July 1999   
   Sig line 4 vacant - apply within   
      
   --- 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