Path: csiph.com!eternal-september.org!feeder.eternal-september.org!nntp.eternal-september.org!.POSTED!not-for-mail From: Tim Rentsch Newsgroups: comp.lang.c Subject: Re: Sort of trivial code challenge - may be interesting to you anyway Date: Fri, 06 Mar 2026 08:46:20 -0800 Organization: A noiseless patient Spider Lines: 54 Message-ID: <86a4wkc3dv.fsf@linuxsc.com> References: <10n80sc$3soe4$1@dont-email.me> <86v7feei2e.fsf@linuxsc.com> <10o53k6$1i0ef$2@dont-email.me> <86ms0peby6.fsf@linuxsc.com> <10o6nci$21m76$1@dont-email.me> <86a4wpdmfi.fsf@linuxsc.com> <10o9c3n$2ul3p$1@dont-email.me> <86ldg7d1a0.fsf@linuxsc.com> <10oes6q$pas6$1@dont-email.me> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Injection-Date: Fri, 06 Mar 2026 16:46:24 +0000 (UTC) Injection-Info: dont-email.me; posting-host="b0f5cdf16a02d5dcd9e415cfd7cb6e85"; logging-data="864636"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX19t3SugSqvrJgAlXG/693lEh8W3prRwCBc=" User-Agent: Gnus/5.11 (Gnus v5.11) Emacs/22.4 (gnu/linux) Cancel-Lock: sha1:KmtqglAar88c5Pje/ZjJ1od9S8Q= sha1:5ZmwPWInqp7YsDrOGchv7oZtL0Q= Xref: csiph.com comp.lang.c:396826 DFS writes: > On 3/4/2026 11:09 AM, Tim Rentsch wrote: > >> DFS writes: >> >>> I recently thought of a new approach: fill an array with 1 to the >>> cutoff (min(cutoff, rows*cols) anyway), and just print the whole array >>> col by row. Then there's never a need to check each value as you're >>> printing it. >> >> Hmmm. Well I give you points for originality. ;) > > I'm sensing sarcasm. I wasn't being sarcastic; I do give you points for originality. I leave it to you to decide how much value to ascribe to that. To be frank I didn't quite understand what you were suggesting. I was waiting for you to post some code so I could see what you meant. > I pursued the array approach (a little differently than I described > above), but in the end it was useless and a waste of time. > > example: 4x4 array looked like this: > > position: 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 > initial : 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 > filled : 1 5 9 13 0 2 6 10 14 0 3 7 11 15 0 4 8 12 16 > printed : > 1 5 9 13 > 2 6 10 14 > 3 7 11 15 > 4 8 12 16 > > When you come to a 0 you do newline. > > Worked great with no cutoffs, but couldn't quite get the printing > right when there were cutoff values. And it ended up being about 50% > MORE code than my original algorithm. And it used an unnecessary > array object. > > Altogether a fail. Exploring a new method, even if unsuccessful, still has value. >> If both of those hints aren't enough, ask again and I'll try to get >> you closer to the goal. > > I'll wait until you post your majestic code. I'm still hoping you will post an attempt first, especially now that you have seen Lew Pitcher's response. If you tell me where you are stuck I can try to give a suitable hint to get you over the hump.