Path: csiph.com!eternal-september.org!feeder.eternal-september.org!.POSTED!not-for-mail From: John Ames Newsgroups: comp.os.linux.misc,comp.os.linux.advocacy Subject: Re: Simple Programming Challenge Date: Wed, 12 Nov 2025 08:07:56 -0800 Organization: A noiseless patient Spider Lines: 23 Message-ID: <20251112080756.00000989@gmail.com> References: <18774b74533f13ac$14097$3668313$802601b3@news.usenetexpress.com> <5L1RQ.59910$3VN7.27458@fx41.iad> MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Injection-Date: Wed, 12 Nov 2025 16:08:00 +0000 (UTC) Injection-Info: dont-email.me; posting-host="366e614e19b1512d2a14771e62457665"; logging-data="1625155"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX19vCrkVEf+Nbq6QfjC/M09DRWVviRtlKu4=" Cancel-Lock: sha1:SERewTUQg4NIWbFNEtNe2fVUcsk= X-Newsreader: Claws Mail 4.3.0 (GTK 3.24.42; x86_64-w64-mingw32) Xref: csiph.com comp.os.linux.misc:77408 comp.os.linux.advocacy:700764 On Wed, 12 Nov 2025 10:31:13 -0500 "Joel W. Crump" wrote: > > Seems trivial, eh? > > > > This is an interview question that I give to my applicants and no > > one has passed yet. > > Why would anyone waste their time on such a lame project? It's a trivial "are you even qualified to be here?" interview question, but yeah, it's not a terribly interesting problem. Assuming you're not on an architecture where division is computationally expensive, and I/O is counted as "free," the only meaningful performance consideration is branching. (If you *are* on an architecture where division is expensive, it might be interesting to exploit the fact that the sum of individual nybbles in a word down to a single nybble - i.e., if sum >= 0x10, recurse - can be compared against 0x5, 0xA, and 0xF to check for divisibility by five and 0x3, 0x6, 0x9, 0xC, and 0xF for divisibility by three, but I'm not sure whether that'd save you any time over Russian-peasant division.)