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


Groups > comp.programming > #16109

Re: Another little puzzle

From Tim Rentsch <tr.17687@z991.linuxsc.com>
Newsgroups comp.programming
Subject Re: Another little puzzle
Date 2022-12-21 13:17 -0800
Organization A noiseless patient Spider
Message-ID <86pmcczcak.fsf@linuxsc.com> (permalink)
References <puzzle-20221214131815@ram.dialup.fu-berlin.de> <algorithm-20221221130021@ram.dialup.fu-berlin.de>

Show all headers | View raw


ram@zedat.fu-berlin.de (Stefan Ram) writes:

> 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.

As before, the problem is underspecified.

What is average( 0700, 1900 ), where the times indicate 24-hour
military times?

What is average( 1900, 0700 )?

What is average( 0100, 0700, 1300, 1900 )?
What is average( 0700, 1300, 1900, 0100 )?
What is average( 1300, 1900, 0100, 0700 )?
What is average( 1900, 0100, 0700, 1300 )?

and similarly for all other permutations of
the four arguments?

Stop giving just examples;  instead give a statement
of the problem that gives correct answers for all
inputs.  Giving just examples is a waste of everyone's
time.

Back to comp.programming | Previous | NextNext in thread | Find similar


Thread

Re: Another little puzzle Tim Rentsch <tr.17687@z991.linuxsc.com> - 2022-12-21 13:17 -0800
  Re: Another little puzzle Ben Bacarisse <ben.usenet@bsb.me.uk> - 2022-12-22 04:10 +0000
    Re: Another little puzzle Tim Rentsch <tr.17687@z991.linuxsc.com> - 2022-12-24 06:21 -0800
      Re: Another little puzzle Mike Terry <news.dead.person.stones@darjeeling.plus.com> - 2022-12-24 16:53 +0000
        Re: Another little puzzle Richard Heathfield <rjh@cpax.org.uk> - 2022-12-24 17:14 +0000
        Re: Another little puzzle Ben Bacarisse <ben.usenet@bsb.me.uk> - 2022-12-24 22:30 +0000
          Re: Another little puzzle Mike Terry <news.dead.person.stones@darjeeling.plus.com> - 2022-12-25 00:02 +0000
            Re: Another little puzzle Ben Bacarisse <ben.usenet@bsb.me.uk> - 2022-12-25 01:30 +0000
            Re: Another little puzzle Ben Bacarisse <ben.usenet@bsb.me.uk> - 2022-12-25 01:55 +0000
        Re: Another little puzzle Tim Rentsch <tr.17687@z991.linuxsc.com> - 2022-12-25 00:37 -0800
      Re: Another little puzzle Ben Bacarisse <ben.usenet@bsb.me.uk> - 2022-12-25 00:41 +0000
        Re: Another little puzzle Tim Rentsch <tr.17687@z991.linuxsc.com> - 2022-12-25 01:05 -0800
          Re: Another little puzzle Tim Rentsch <tr.17687@z991.linuxsc.com> - 2022-12-25 09:30 -0800
          Re: Another little puzzle Ben Bacarisse <ben.usenet@bsb.me.uk> - 2022-12-25 21:44 +0000
            Re: Another little puzzle Richard Damon <Richard@Damon-Family.org> - 2022-12-25 17:59 -0500
              Re: Another little puzzle Tim Rentsch <tr.17687@z991.linuxsc.com> - 2022-12-25 18:39 -0800
              Re: Another little puzzle Ben Bacarisse <ben.usenet@bsb.me.uk> - 2022-12-26 03:18 +0000
            Re: Another little puzzle Tim Rentsch <tr.17687@z991.linuxsc.com> - 2022-12-25 18:35 -0800
              Re: Another little puzzle Ben Bacarisse <ben.usenet@bsb.me.uk> - 2022-12-26 03:49 +0000

csiph-web