Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.programming > #16105

Re: Another little puzzle

From Ben Bacarisse <ben.usenet@bsb.me.uk>
Newsgroups comp.programming
Subject Re: Another little puzzle
Date 2022-12-21 17:05 +0000
Organization A noiseless patient Spider
Message-ID <874jtovgao.fsf@bsb.me.uk> (permalink)
References <puzzle-20221214131815@ram.dialup.fu-berlin.de> <algorithm-20221221130021@ram.dialup.fu-berlin.de> <tnv0ia$uein$3@dont-email.me>

Show all headers | View raw


Richard Heathfield <rjh@cpax.org.uk> 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.

Back to comp.programming | Previous | NextPrevious in thread | Next in thread | Find similar


Thread

Re: Another little puzzle Richard Heathfield <rjh@cpax.org.uk> - 2022-12-21 13:09 +0000
  Re: Another little puzzle Ben Bacarisse <ben.usenet@bsb.me.uk> - 2022-12-21 17:05 +0000
    Re: Another little puzzle Richard Heathfield <rjh@cpax.org.uk> - 2022-12-21 17:21 +0000
    Re: Another little puzzle "Dmitry A. Kazakov" <mailbox@dmitry-kazakov.de> - 2022-12-21 18:55 +0100
      Re: Another little puzzle Mike Terry <news.dead.person.stones@darjeeling.plus.com> - 2022-12-21 19:55 +0000
        Re: Another little puzzle "Dmitry A. Kazakov" <mailbox@dmitry-kazakov.de> - 2022-12-21 22:54 +0100
          Re: Another little puzzle Mike Terry <news.dead.person.stones@darjeeling.plus.com> - 2022-12-22 00:01 +0000
            Re: Another little puzzle Julio Di Egidio <julio@diegidio.name> - 2022-12-21 16:05 -0800
              Re: Another little puzzle David Brown <david.brown@hesbynett.no> - 2022-12-22 16:50 +0100
                Re: Another little puzzle Julio Di Egidio <julio@diegidio.name> - 2022-12-22 08:30 -0800
                Re: Another little puzzle David Brown <david.brown@hesbynett.no> - 2022-12-22 22:06 +0100
                Re: Another little puzzle Richard Heathfield <rjh@cpax.org.uk> - 2022-12-22 21:30 +0000
                Re: Another little puzzle David Brown <david.brown@hesbynett.no> - 2022-12-23 13:46 +0100
                Re: Another little puzzle Y A <angel0000000001000000000000@mail.ee> - 2023-01-09 21:26 -0800
                Re: Another little puzzle Julio Di Egidio <julio@diegidio.name> - 2022-12-22 14:15 -0800
                Re: Another little puzzle David Brown <david.brown@hesbynett.no> - 2022-12-23 13:47 +0100
                Re: Another little puzzle Julio Di Egidio <julio@diegidio.name> - 2022-12-23 08:33 -0800
                Re: Another little puzzle Julio Di Egidio <julio@diegidio.name> - 2022-12-25 15:52 -0800
                Re: Another little puzzle Julio Di Egidio <julio@diegidio.name> - 2022-12-26 06:32 -0800
                Re: Another little puzzle Julio Di Egidio <julio@diegidio.name> - 2022-12-26 06:34 -0800
              Re: Another little puzzle Julio Di Egidio <julio@diegidio.name> - 2022-12-23 08:35 -0800
            Re: Another little puzzle "Dmitry A. Kazakov" <mailbox@dmitry-kazakov.de> - 2022-12-22 09:10 +0100
          Re: Another little puzzle Ǝ <angel00000100000@mail.ee> - 2022-12-30 18:18 -0800
        Re: Another little puzzle Julio Di Egidio <julio@diegidio.name> - 2022-12-21 14:47 -0800
          Re: Another little puzzle Julio Di Egidio <julio@diegidio.name> - 2022-12-23 08:35 -0800
          Re: Another little puzzle Julio Di Egidio <julio@diegidio.name> - 2022-12-25 15:52 -0800
            Re: Another little puzzle Julio Di Egidio <julio@diegidio.name> - 2022-12-26 06:32 -0800
          Re: Another little puzzle Julio Di Egidio <julio@diegidio.name> - 2022-12-26 06:33 -0800
          Re: Another little puzzle Y A <angel0000000001000000000000@mail.ee> - 2023-01-09 21:26 -0800

csiph-web