Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.programming > #16082
| From | Richard Heathfield <rjh@cpax.org.uk> |
|---|---|
| Newsgroups | comp.programming |
| Subject | Re: Another little puzzle |
| Date | 2022-12-14 15:18 +0000 |
| Organization | Fix this later |
| Message-ID | <tncpgk$2of9h$7@dont-email.me> (permalink) |
| References | (1 earlier) <tncho3$ilr$1@gioia.aioe.org> <tnci0u$2of9h$3@dont-email.me> <tncjem$19kh$1@gioia.aioe.org> <tnclg3$2of9o$2@dont-email.me> <tncob5$1oat$1@gioia.aioe.org> |
On 14/12/2022 2:58 pm, Dmitry A. Kazakov wrote: > On 2022-12-14 15:10, Richard Heathfield wrote: >> On 14/12/2022 1:35 pm, Dmitry A. Kazakov wrote: >>> On 2022-12-14 14:10, Richard Heathfield wrote: >>>> On 14/12/2022 1:06 pm, Dmitry A. Kazakov wrote: >>>>> On 2022-12-14 13:24, Stefan Ram wrote: >>>>>> 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 probably missed to require the interesting part: doing >>>>> all that in the modular type (modulo 24) arithmetic: >>>>> >>>>> 20 + 5 = 1 (mod 24) >>>> >>>> ...which will give you the wrong answer. Chase that goose! >>> >>> Right, you must count the wrap-ups. > > [...] > >> So why do you need mod? > > As I said, the challenge is only interesting in modulo arithmetic So the challenge is only interesting if you add something you don't need. Let's throw in some elephants. Does that make it more interesting? > BTW, averaging floats is a nasty problem too. A naive > implementation quickly loses precision. We're dealing with 'o'clock' and "HH:MM", and nowadays we have 64-bit integer types and there are even 128-bit integers mooching around looking for a reason to exist. You'd have to average a hell of a lot of times even to /need/ floats, let alone lose significant precision. -- 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
Back to comp.programming | Previous | Next — Previous in thread | Next in thread | Find similar
Re: Another little puzzle "Dmitry A. Kazakov" <mailbox@dmitry-kazakov.de> - 2022-12-14 14:06 +0100
Re: Another little puzzle Richard Heathfield <rjh@cpax.org.uk> - 2022-12-14 13:10 +0000
Re: Another little puzzle "Dmitry A. Kazakov" <mailbox@dmitry-kazakov.de> - 2022-12-14 14:35 +0100
Re: Another little puzzle Richard Heathfield <rjh@cpax.org.uk> - 2022-12-14 14:10 +0000
Re: Another little puzzle "Dmitry A. Kazakov" <mailbox@dmitry-kazakov.de> - 2022-12-14 15:58 +0100
Re: Another little puzzle Richard Heathfield <rjh@cpax.org.uk> - 2022-12-14 15:18 +0000
Re: Another little puzzle "Dmitry A. Kazakov" <mailbox@dmitry-kazakov.de> - 2022-12-14 16:41 +0100
Re: Another little puzzle "Dmitry A. Kazakov" <mailbox@dmitry-kazakov.de> - 2022-12-14 16:43 +0100
Re: Another little puzzle Y A <angel00000100000@mail.ee> - 2023-01-09 16:33 -0800
Re: Another little puzzle Richard Heathfield <rjh@cpax.org.uk> - 2022-12-14 16:13 +0000
Re: Another little puzzle V <angleeeeeeee@mail.ee> - 2023-05-10 11:16 -0700
Re: Another little puzzle Ǝ <angel0000000001000000000000@mail.ee> - 2022-12-30 05:59 -0800
csiph-web