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: Thu, 05 Mar 2026 15:08:17 -0800
Organization: A noiseless patient Spider
Lines: 42
Message-ID: <86qzpxc1su.fsf@linuxsc.com>
References: <10n80sc$3soe4$1@dont-email.me> <86v7feei2e.fsf@linuxsc.com> <10o53k6$1i0ef$2@dont-email.me> <86ms0peby6.fsf@linuxsc.com> <10ockdh$3qpk6$1@dont-email.me> <10ocrjn$3qpk6$2@dont-email.me> <86zf4mapto.fsf@linuxsc.com> <10ocvrk$3qpk6$3@dont-email.me> <20260306010016.0000729e@yahoo.com>
MIME-Version: 1.0
Content-Type: text/plain; charset=us-ascii
Injection-Date: Thu, 05 Mar 2026 23:08:19 +0000 (UTC)
Injection-Info: dont-email.me; posting-host="e10200766ffc466ebfe6a0b9c1907eec"; logging-data="229228"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+GKXv1IjNLFL2sC5XD65Y8UnVFzZX42c4="
User-Agent: Gnus/5.11 (Gnus v5.11) Emacs/22.4 (gnu/linux)
Cancel-Lock: sha1:MoKAU5EA4vqbEPktWWquDRFYD6I= sha1:ddHbqUKMYubhKIh0TDVM4avQn8k=
Xref: csiph.com comp.lang.c:396803
Michael S writes:
> On Thu, 5 Mar 2026 22:24:53 -0000 (UTC)
> Lew Pitcher wrote:
>
>> On Thu, 05 Mar 2026 14:12:19 -0800, Tim Rentsch wrote:
>>
>>> Lew Pitcher writes:
>>>
>>>> On Thu, 05 Mar 2026 19:09:37 +0000, Lew Pitcher wrote:
>>>>
>>>>> On Mon, 02 Mar 2026 21:09:21 -0800, Tim Rentsch wrote:
>>>>> [snip]
>>>>>
>>>>>> The latest challenge, which I just got through doing, is to
>>>>>> disallow if, for, while, goto, return, and to forbid functions
>>>>>> and function calls except for calls to C standard library
>>>>>> functions. Also no math library. :)
>>>>>
>>>>> Inventive, aren't you :-)
>>>>>
>>>>> I've got a working matrix print that (I think) satisfies your
>>>>> requirements, but have not started on the argument processing
>>>>> logic yet. I may, yet again, revise my approach, as the solution
>>>>> I'm using is quite tedious to code.
>>>>
>>>> OK, so the "no if statements" is a bit of a bother, but not
>>>> insurmountable. It's just a case of switching things around.
>>>> And, perhaps there's a third option as well.
>>>>
>>>> As I said, the alternatives are just tedious to code.
>>>
>>> I did manage to find some tricks to make things simpler, but
>>> probably the most important is ?: is your friend.
>>
>> that, and switch()/case, which is a nice substitute for if ()
>> statements with complex bodies, or if () / else statements.
>
> My impression was that switch is omitted from the list of disallowed
> constructs by mistake.
Definitely not. Use of switch() is allowed (and 'case' also).