Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.programming > #11787
| From | David Brown <david.brown@hesbynett.no> |
|---|---|
| Newsgroups | comp.programming |
| Subject | Re: C o m p e t i t i o n . |
| Date | 2021-01-15 13:56 +0100 |
| Organization | A noiseless patient Spider |
| Message-ID | <rts3dr$4pm$1@dont-email.me> (permalink) |
| References | (7 earlier) <rtmdkt$fro$1@dont-email.me> <93b7395f-168b-4010-8f63-fc36c8c7de6dn@googlegroups.com> <rtnjjk$2ci$1@dont-email.me> <fu26dh-n43.ln1@aretha.foo> <87czy7avzk.fsf@bsb.me.uk> |
On 15/01/2021 01:23, Ben Bacarisse wrote: > Peter 'Shaggy' Haywood <phaywood@alphalink.com.au> writes: > >> Groovy hepcat Richard Heathfield was jivin' in comp.programming on Thu, >> 14 Jan 2021 07:01 am. It's a cool scene! Dig it. >> >>> On 13/01/2021 10:31, Y A wrote: >>>> Richard Heathfield kirjutas kolmapäev, 13. jaanuar 2021 kl 11:14:09 >>>> UTC+2: >>>>> On 12/01/2021 23:25, Y A wrote: >>>>>> Richard Heathfield kirjutas teisipäev, 12. jaanuar 2021 kl 18:17:01 >>>>>> UTC+2: >>>>>>> On 12/01/2021 13:17, I I wrote: >>>>>>> >>>>>>> <snip> >>>>>>>> I am so sorry, that You have not attended school . . . . . . >>>>>>> Irony is always amusing, but the more so when unintentional. >>>>>> >>>>>> Hmmmmmmmmmmmmmmmmmmmm........................... >>>>>> Cross sum isn't logically: sum of all digits? >>>>>> abcde cs=a+b+c+d+e >>>>> I'd never heard the term before the OP used it at the beginning of >>>>> this thread, so I looked it up. >>>>> >>>>> The only meaning I could find for it online was "sum of all digits" >>>>> (i.e. the digital root), so I calculated the sum of all digits. >>>>> >>>>> Presumably the OP (who has a different result) means something >>>>> different by it, but he appears unwilling to share that meaning with >>>>> us. >>>> >>>> OP=me >>> >>> Then you ought to know what you mean by "cross sum", so you ought to >>> be in a position to share that information. >>> >>> If you mean "digital root", I've already given the correct answer, >>> which you say is different to your answer, which means you're wrong. >> >> Just to add my two cents to this discussion, for what it's worth >> (somewhere between one and three cents, presumably), I wrote, compiled >> and ran the following program. It bears out Richard's results. > > Indeed (I would expect nothing else). But the result is dependent on > the base so there is some ambiguity in the question. > > Here is a Haskell program (well, some Haskell functions) that can give > the answer for various bases: > > digits b n = if n == 0 then [] else r : digits b q > where (q, r) = divMod n b > > dSum b n = sum $ digits b n > > crossSum b n = head $ dropWhile (>= b) $ iterate (dSum b) n > > *Main> let n = 58349863148967341986793418678943167894317568943579812347643263461438776834177468314765864533703574653715456716465804656089576907569568456680257542768434686845796847604780607596864802468874265807426587026578406466539046579467684906749046758049663588463065836688638658768635806365889683658746862486247487652774625076485806648907696785970467957869053868763688046236880752825686569877668097860897676807746897456368844688745768468242622686282862869874986865749685796854096857706759759674569074359357697539375903576096780074367589368590356896686539 > *Main> dSum 10 n > 2977 > *Main> crossSum 10 n > 7 > *Main> crossSum 2 n > 1 > *Main> crossSum 5 n > 3 > And a Python implementation: >>> def cs(ys) : ... return sum([int(x) for x in str(ys)]) >>> cs(xs) 2977 >>> cs(cs(xs)) 25 >>> cs(cs(cs(xs))) 7
Back to comp.programming | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
C o m p e t i t i o n . I I <he12457@hotmail.com> - 2021-01-09 11:25 -0800
Re: C o m p e t i t i o n . Richard Heathfield <rjh@cpax.org.uk> - 2021-01-10 09:21 +0000
Re: C o m p e t i t i o n . I I <he12457@hotmail.com> - 2021-01-10 12:01 -0800
Re: C o m p e t i t i o n . Richard Heathfield <rjh@cpax.org.uk> - 2021-01-10 22:15 +0000
Re: C o m p e t i t i o n . I I <kpuctjanpobam@mail.com> - 2021-01-12 05:17 -0800
Re: C o m p e t i t i o n . Richard Heathfield <rjh@cpax.org.uk> - 2021-01-12 16:16 +0000
Re: C o m p e t i t i o n . Y A <kpuctjanpobam@mail.com> - 2021-01-12 15:25 -0800
Re: C o m p e t i t i o n . Richard Heathfield <rjh@cpax.org.uk> - 2021-01-13 09:14 +0000
Re: C o m p e t i t i o n . Y A <kpuctjanpobam@mail.com> - 2021-01-13 02:31 -0800
Re: C o m p e t i t i o n . Richard Heathfield <rjh@cpax.org.uk> - 2021-01-13 20:01 +0000
Re: C o m p e t i t i o n . ند ارائه نماييدبا تشکر ند ارائه نمايي تش <kpuctjanpobam@mail.com> - 2021-01-14 08:29 -0800
Re: C o m p e t i t i o n . ند ارائه نماييدبا تشکر ند ارائه نمايي تش <kpuctjanpobam@mail.com> - 2021-01-14 08:48 -0800
Re: C o m p e t i t i o n . Richard Heathfield <rjh@cpax.org.uk> - 2021-01-14 19:16 +0000
Re: C o m p e t i t i o n . H e <he12457@hotmail.com> - 2021-01-14 11:28 -0800
Re: C o m p e t i t i o n . Richard Heathfield <rjh@cpax.org.uk> - 2021-01-15 07:46 +0000
Re: C o m p e t i t i o n . Peter 'Shaggy' Haywood <phaywood@alphalink.com.au> - 2021-01-17 23:23 +1100
Re: C o m p e t i t i o n . Richard Heathfield <rjh@cpax.org.uk> - 2021-01-22 06:36 +0000
Re: C o m p e t i t i o n . David Brown <david.brown@hesbynett.no> - 2021-01-15 11:13 +0100
Re: C o m p e t i t i o n . Peter 'Shaggy' Haywood <phaywood@alphalink.com.au> - 2021-01-15 02:01 +1100
Re: C o m p e t i t i o n . Ben Bacarisse <ben.usenet@bsb.me.uk> - 2021-01-15 00:23 +0000
Re: C o m p e t i t i o n . David Brown <david.brown@hesbynett.no> - 2021-01-15 13:56 +0100
Re: C o m p e t i t i o n . H e <he12457@hotmail.com> - 2021-01-17 03:23 -0800
Re: C o m p e t i t i o n . Richard Heathfield <rjh@cpax.org.uk> - 2021-01-17 18:43 +0000
csiph-web