Path: csiph.com!eternal-september.org!reader02.eternal-september.org!.POSTED!not-for-mail
From: Tim Rentsch
Newsgroups: comp.lang.c
Subject: Re: Programming exercise/challenge
Date: Sun, 06 Dec 2020 06:13:28 -0800
Organization: A noiseless patient Spider
Lines: 46
Message-ID: <86y2ibja47.fsf@linuxsc.com>
References: <86wnxwkyol.fsf@linuxsc.com> <5MQyH.103588$lo15.100353@fx35.iad>
Mime-Version: 1.0
Content-Type: text/plain; charset=us-ascii
Injection-Info: reader02.eternal-september.org; posting-host="048215ee9820886844dd3aade67dded3"; logging-data="31388"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+MRY2xGGv3R0deyJFskAAfy8wv4p0iVaI="
User-Agent: Gnus/5.11 (Gnus v5.11) Emacs/22.4 (gnu/linux)
Cancel-Lock: sha1:plOgMt022j+DNk7mAHy/eB0xiIw= sha1:y9nJW17D7C1UacymGxH4u87ZfsM=
Xref: csiph.com comp.lang.c:156979
Jorgen Grahn writes:
> On Sat, 2020-12-05, dfs wrote:
>
>> On 12/05/2020 11:25 AM, Tim Rentsch wrote:
>>
>>> Prompted by some recent discussion regarding 'goto' statements and
>>> state machines, I would like to propose a programming exercise.
>>> (It is perhaps a bit too large to be called an exercise, but not so
>>> difficult that it deserves the label of challenge. On the other
>>> hand there are some constraints so maybe challenge is apropos. In
>>> any case somewhere in between those two bounds.)
>>>
>>> Short problem statement: a C program to remove comments from C
>>> source input.
>>>
>>> Specifics: Remove both /*...*/ and //... style comments. Don't
>>> worry about trigraphs. Read from stdin, write to stdout, and
>>> diagnostics (if any) go to stderr. If EOF is seen inside a
>>> comment, do something sensible but it doesn't matter what as long
>>> as it's sensible. Use no 'goto' statements. Limit function
>>> bodies to no more than 25 lines.
>>>
>>> Other: feel free to handle corner cases as you see fit, as long
>>> as there is some description of what choice was made.
>>>
>>> Hopefully it will be a fun exercise. It isn't trivial but it
>>> shouldn't take too long either.
>>
>> Shortest code "wins"?
>
> He didn't say anything about that, and code size isn't a good
> indicator of anything, so I'd say "no".
Right.
> It's a nice problem.
Thank you sir. Always good to hear.
> (Unfortunately I'm participating in Advent of Code already, and
> together with hobby projects that takes up all my programming
> attention.)
Sorry to hear you won't have time for this one, but good luck
with your other efforts.