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,792 of 57,431   
   Ben Bacarisse to Richard Heathfield   
   Re: Another little puzzle   
   21 Dec 22 17:05:03   
   
   From: ben.usenet@bsb.me.uk   
      
   Richard Heathfield  writes:   
      
   > 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.   
      
   I don't think it's reasonable to call it a mistake.  There is a   
   perfectly plausible interpretation of "average" that gives 0.5.  My   
   (un-posted) code gives 0.5.   
      
   I think the one day/two days distinction might be a distraction.  Can   
   you say more about how that distinction changes the answer?  (Mind you,   
   I can't see how SR's words imply one day.)   
      
   >> 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.   
      
   Hmm...  My interpretation of average gives 0.5.  Mind you, I just took   
   some exiting related code and changed degrees into hours.  That mapping   
   seemed to me to match up with what SR was driving at.   
      
   >>    I believe that I have not seen an algorithm so far in this   
   >>    thread that would pass these tests.   
   >   
   > You misunderstood your specification.   
      
   That's very severe!   
      
   --   
   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