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,784 of 57,431   
   Stefan Ram to Stefan Ram   
   Re: Another little puzzle   
   21 Dec 22 12:03:27   
   
   From: ram@zedat.fu-berlin.de   
      
   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   
   average( 11.5, 13.5 )== 12.5   
      
     (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.   
      
     I believe that I have not seen an algorithm so far in this   
     thread that would pass these tests.   
      
   --- 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