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: Mon, 02 Mar 2026 00:44:57 -0800
Organization: A noiseless patient Spider
Lines: 33
Message-ID: <86v7feei2e.fsf@linuxsc.com>
References: <10n80sc$3soe4$1@dont-email.me>
MIME-Version: 1.0
Content-Type: text/plain; charset=us-ascii
Injection-Date: Mon, 02 Mar 2026 08:45:03 +0000 (UTC)
Injection-Info: dont-email.me; posting-host="879346d16fc7c1cd3f18baf5c462c148"; logging-data="1046631"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX18gUgVC6HmtqxrgccFZyYz9EpuTZI250w0="
User-Agent: Gnus/5.11 (Gnus v5.11) Emacs/22.4 (gnu/linux)
Cancel-Lock: sha1:Mlmke83kPUWyjOM8Ee2OWK5whOQ= sha1:R+sJywyp0nKI1YQbwdg0BdPpFyo=
Xref: csiph.com comp.lang.c:396724
DFS writes:
> Challenge is to output sequential numbers by column then row:
>
> 1 6 11 16 21
> 2 7 12 17 22
> 3 8 13 18 23
> 4 9 14 19 24
> 5 10 15 20 25
[...]
> Simple enough. But the following 2 requirements take it from trivial
> to less trivial!
>
> --------------------------------------------------------------------
> 1) must be able to cut the output off at any arbitrary value
> lower than rows x columns
> --------------------------------------------------------------------
[...]
> --------------------------------------------------------------------
> 2) if you don't specify rows and columns, your solution must try
> to calculate them to form a square (same # of rows and columns)
> that includes only 1 to N.
>
> If rows=columns can't be calculated, return message 'not possible'
> --------------------------------------------------------------------
A straightfoward exercise. Here is a counter challenge to make
things more interesting: as above, but don't use nested loops
(or goto's, etc).