Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.c > #396684 > unrolled thread

Sort of trivial code challenge - may be interesting to you anyway

Started byDFS <nospam@dfs.com>
First post2026-02-19 16:55 -0500
Last post2026-03-16 09:04 +0100
Articles 20 on this page of 218 — 21 participants

Back to article view | Back to comp.lang.c


Contents

  Sort of trivial code challenge - may be interesting to you anyway DFS <nospam@dfs.com> - 2026-02-19 16:55 -0500
    Re: Sort of trivial code challenge - may be interesting to you anyway jayjwa <jayjwa@atr2.ath.cx.invalid> - 2026-02-25 15:56 -0500
      Re: Sort of trivial code challenge - may be interesting to you anyway DFS <nospam@dfs.com> - 2026-02-26 10:05 -0500
        Re: Sort of trivial code challenge - may be interesting to you anyway jayjwa <jayjwa@atr2.ath.cx.invalid> - 2026-02-26 13:20 -0500
    Re: Sort of trivial code challenge - may be interesting to you anyway Lew Pitcher <lew.pitcher@digitalfreehold.ca> - 2026-02-26 17:06 +0000
      Re: Sort of trivial code challenge - may be interesting to you anyway Lew Pitcher <lew.pitcher@digitalfreehold.ca> - 2026-02-26 17:27 +0000
        Re: Sort of trivial code challenge - may be interesting to you anyway DFS <nospam@dfs.com> - 2026-02-26 14:31 -0500
      Re: Sort of trivial code challenge - may be interesting to you anyway jayjwa <jayjwa@atr2.ath.cx.invalid> - 2026-02-26 13:33 -0500
        Re: Sort of trivial code challenge - may be interesting to you anyway Lew Pitcher <lew.pitcher@digitalfreehold.ca> - 2026-02-26 18:49 +0000
          Re: Sort of trivial code challenge - may be interesting to you anyway Lew Pitcher <lew.pitcher@digitalfreehold.ca> - 2026-02-26 18:55 +0000
            Re: Sort of trivial code challenge - may be interesting to you anyway Lew Pitcher <lew.pitcher@digitalfreehold.ca> - 2026-02-26 19:17 +0000
      Re: Sort of trivial code challenge - may be interesting to you anyway Lew Pitcher <lew.pitcher@digitalfreehold.ca> - 2026-02-26 19:34 +0000
        Re: Sort of trivial code challenge - may be interesting to you anyway Lew Pitcher <lew.pitcher@digitalfreehold.ca> - 2026-02-26 20:01 +0000
        Re: Sort of trivial code challenge - may be interesting to you anyway DFS <nospam@dfs.com> - 2026-03-06 10:36 -0500
          Re: Sort of trivial code challenge - may be interesting to you anyway Lew Pitcher <lew.pitcher@digitalfreehold.ca> - 2026-03-06 17:38 +0000
            Re: Sort of trivial code challenge - may be interesting to you anyway Lew Pitcher <lew.pitcher@digitalfreehold.ca> - 2026-03-06 17:48 +0000
    Re: Sort of trivial code challenge - may be interesting to you anyway Bart <bc@freeuk.com> - 2026-02-27 00:12 +0000
      [OT] Bart's scripting language solution (was Re: Sort of trivial code challenge - may be interesting to you anyway) Janis Papanagnou <janis_papanagnou@hotmail.com> - 2026-03-06 06:37 +0100
        Re: [OT] Bart's scripting language solution (was Re: Sort of trivial code challenge - may be interesting to you anyway) Bart <bc@freeuk.com> - 2026-03-06 15:48 +0000
          Re: [OT] Bart's scripting language solution (was Re: Sort of trivial code challenge - may be interesting to you anyway) Janis Papanagnou <janis_papanagnou@hotmail.com> - 2026-03-06 18:17 +0100
            Re: [OT] Bart's scripting language solution (was Re: Sort of trivial code challenge - may be interesting to you anyway) Bart <bc@freeuk.com> - 2026-03-06 21:46 +0000
    Re: Sort of trivial code challenge - may be interesting to you anyway Tim Rentsch <tr.17687@z991.linuxsc.com> - 2026-03-02 00:44 -0800
      Re: Sort of trivial code challenge - may be interesting to you anyway Michael S <already5chosen@yahoo.com> - 2026-03-02 11:07 +0200
        Re: Sort of trivial code challenge - may be interesting to you anyway Tim Rentsch <tr.17687@z991.linuxsc.com> - 2026-03-02 06:35 -0800
          Re: Sort of trivial code challenge - may be interesting to you anyway Bart <bc@freeuk.com> - 2026-03-02 17:50 +0000
            Re: Sort of trivial code challenge - may be interesting to you anyway Tim Rentsch <tr.17687@z991.linuxsc.com> - 2026-03-02 21:15 -0800
              Re: Sort of trivial code challenge - may be interesting to you anyway Bart <bc@freeuk.com> - 2026-03-03 20:48 +0000
                Re: Sort of trivial code challenge - may be interesting to you anyway Janis Papanagnou <janis_papanagnou+ng@hotmail.com> - 2026-03-03 22:47 +0100
                  Re: Sort of trivial code challenge - may be interesting to you anyway David Brown <david.brown@hesbynett.no> - 2026-03-04 08:48 +0100
                    Re: Sort of trivial code challenge - may be interesting to you anyway Keith Thompson <Keith.S.Thompson+u@gmail.com> - 2026-03-04 01:07 -0800
                      Re: Sort of trivial code challenge - may be interesting to you anyway Michael S <already5chosen@yahoo.com> - 2026-03-04 12:09 +0200
                        Re: Sort of trivial code challenge - may be interesting to you anyway Keith Thompson <Keith.S.Thompson+u@gmail.com> - 2026-03-04 11:19 -0800
                      Re: Sort of trivial code challenge - may be interesting to you anyway David Brown <david.brown@hesbynett.no> - 2026-03-04 12:58 +0100
                        Re: Sort of trivial code challenge - may be interesting to you anyway Bonita Montero <Bonita.Montero@gmail.com> - 2026-03-11 11:31 +0100
                  Re: Sort of trivial code challenge - may be interesting to you anyway Bart <bc@freeuk.com> - 2026-03-04 13:20 +0000
                Re: Sort of trivial code challenge - may be interesting to you anyway DFS <nospam@dfs.com> - 2026-03-04 08:30 -0500
                  Re: Sort of trivial code challenge - may be interesting to you anyway Bart <bc@freeuk.com> - 2026-03-04 14:36 +0000
                    Re: Sort of trivial code challenge - may be interesting to you anyway DFS <nospam@dfs.com> - 2026-03-04 10:02 -0500
                      Re: Sort of trivial code challenge - may be interesting to you anyway Michael S <already5chosen@yahoo.com> - 2026-03-04 19:27 +0200
                        Re: Sort of trivial code challenge - may be interesting to you anyway DFS <nospam@dfs.com> - 2026-03-05 13:49 -0500
                          Re: Sort of trivial code challenge - may be interesting to you anyway Michael S <already5chosen@yahoo.com> - 2026-03-05 21:02 +0200
                          Re: Sort of trivial code challenge - may be interesting to you anyway Bart <bc@freeuk.com> - 2026-03-05 20:39 +0000
                            Re: Sort of trivial code challenge - may be interesting to you anyway DFS <nospam@dfs.com> - 2026-03-05 19:24 -0500
                        Re: Sort of trivial code challenge - may be interesting to you anyway Tim Rentsch <tr.17687@z991.linuxsc.com> - 2026-03-05 13:54 -0800
                Re: Sort of trivial code challenge - may be interesting to you anyway Tim Rentsch <tr.17687@z991.linuxsc.com> - 2026-03-12 05:50 -0700
                  Re: Sort of trivial code challenge - may be interesting to you anyway Bart <bc@freeuk.com> - 2026-03-13 11:58 +0000
                    Re: Sort of trivial code challenge - may be interesting to you anyway Bart <bc@freeuk.com> - 2026-03-13 23:00 +0000
                      Re: Sort of trivial code challenge - may be interesting to you anyway Tim Rentsch <tr.17687@z991.linuxsc.com> - 2026-03-15 15:54 -0700
                        Re: Sort of trivial code challenge - may be interesting to you anyway Bart <bc@freeuk.com> - 2026-03-15 23:42 +0000
                          Re: Sort of trivial code challenge - may be interesting to you anyway Tim Rentsch <tr.17687@z991.linuxsc.com> - 2026-04-06 12:02 -0700
                    Re: Sort of trivial code challenge - may be interesting to you anyway Tim Rentsch <tr.17687@z991.linuxsc.com> - 2026-03-15 15:43 -0700
      Re: Sort of trivial code challenge - may be interesting to you anyway DFS <nospam@dfs.com> - 2026-03-02 17:40 -0500
        Re: Sort of trivial code challenge - may be interesting to you anyway Tim Rentsch <tr.17687@z991.linuxsc.com> - 2026-03-02 21:09 -0800
          Re: Sort of trivial code challenge - may be interesting to you anyway DFS <nospam@dfs.com> - 2026-03-03 08:23 -0500
            Re: Sort of trivial code challenge - may be interesting to you anyway Tim Rentsch <tr.17687@z991.linuxsc.com> - 2026-03-03 06:20 -0800
              Re: Sort of trivial code challenge - may be interesting to you anyway Michael S <already5chosen@yahoo.com> - 2026-03-03 23:56 +0200
                Re: Sort of trivial code challenge - may be interesting to you anyway Tim Rentsch <tr.17687@z991.linuxsc.com> - 2026-03-03 15:51 -0800
                  Re: Sort of trivial code challenge - may be interesting to you anyway Michael S <already5chosen@yahoo.com> - 2026-03-04 11:45 +0200
                    Re: Sort of trivial code challenge - may be interesting to you anyway Tim Rentsch <tr.17687@z991.linuxsc.com> - 2026-03-04 07:01 -0800
                Re: Sort of trivial code challenge - may be interesting to you anyway Bonita Montero <Bonita.Montero@gmail.com> - 2026-03-11 11:37 +0100
              Re: Sort of trivial code challenge - may be interesting to you anyway DFS <nospam@dfs.com> - 2026-03-04 08:29 -0500
                Re: Sort of trivial code challenge - may be interesting to you anyway Janis Papanagnou <janis_papanagnou+ng@hotmail.com> - 2026-03-04 16:02 +0100
                Re: Sort of trivial code challenge - may be interesting to you anyway Tim Rentsch <tr.17687@z991.linuxsc.com> - 2026-03-04 08:09 -0800
                  Re: Sort of trivial code challenge - may be interesting to you anyway DFS <nospam@dfs.com> - 2026-03-06 10:34 -0500
                    Re: Sort of trivial code challenge - may be interesting to you anyway Tim Rentsch <tr.17687@z991.linuxsc.com> - 2026-03-06 08:46 -0800
                Re: Sort of trivial code challenge - may be interesting to you anyway Keith Thompson <Keith.S.Thompson+u@gmail.com> - 2026-03-04 11:25 -0800
                  Re: Sort of trivial code challenge - may be interesting to you anyway DFS <nospam@dfs.com> - 2026-03-05 13:46 -0500
                    Re: Sort of trivial code challenge - may be interesting to you anyway David Brown <david.brown@hesbynett.no> - 2026-03-05 21:34 +0100
          Re: Sort of trivial code challenge - may be interesting to you anyway Lew Pitcher <lew.pitcher@digitalfreehold.ca> - 2026-03-05 19:09 +0000
            Re: Sort of trivial code challenge - may be interesting to you anyway Lew Pitcher <lew.pitcher@digitalfreehold.ca> - 2026-03-05 21:12 +0000
              Re: Sort of trivial code challenge - may be interesting to you anyway Tim Rentsch <tr.17687@z991.linuxsc.com> - 2026-03-05 14:12 -0800
                Re: Sort of trivial code challenge - may be interesting to you anyway Lew Pitcher <lew.pitcher@digitalfreehold.ca> - 2026-03-05 22:24 +0000
                  Re: Sort of trivial code challenge - may be interesting to you anyway Michael S <already5chosen@yahoo.com> - 2026-03-06 01:00 +0200
                    Re: Sort of trivial code challenge - may be interesting to you anyway Tim Rentsch <tr.17687@z991.linuxsc.com> - 2026-03-05 15:08 -0800
                  Re: Sort of trivial code challenge - may be interesting to you anyway Tim Rentsch <tr.17687@z991.linuxsc.com> - 2026-03-05 15:05 -0800
              Re: Sort of trivial code challenge - may be interesting to you anyway Janis Papanagnou <janis_papanagnou@hotmail.com> - 2026-03-06 00:18 +0100
                Re: Sort of trivial code challenge - may be interesting to you anyway Michael S <already5chosen@yahoo.com> - 2026-03-07 22:04 +0200
                  Re: Sort of trivial code challenge - may be interesting to you anyway Janis Papanagnou <janis_papanagnou@hotmail.com> - 2026-03-08 00:26 +0100
                    Re: Sort of trivial code challenge - may be interesting to you anyway Michael S <already5chosen@yahoo.com> - 2026-03-08 02:45 +0200
                      Re: Sort of trivial code challenge - may be interesting to you anyway Janis Papanagnou <janis_papanagnou@hotmail.com> - 2026-03-08 17:05 +0100
                  Re: Sort of trivial code challenge - may be interesting to you anyway Tim Rentsch <tr.17687@z991.linuxsc.com> - 2026-03-11 07:57 -0700
              Re: Sort of trivial code challenge - may be interesting to you anyway Lew Pitcher <lew.pitcher@digitalfreehold.ca> - 2026-03-06 00:12 +0000
                Re: Sort of trivial code challenge - may be interesting to you anyway Lew Pitcher <lew.pitcher@digitalfreehold.ca> - 2026-03-06 00:14 +0000
                Re: Sort of trivial code challenge - may be interesting to you anyway Tim Rentsch <tr.17687@z991.linuxsc.com> - 2026-03-05 20:31 -0800
                  Re: Sort of trivial code challenge - may be interesting to you anyway Lew Pitcher <lew.pitcher@digitalfreehold.ca> - 2026-03-06 13:51 +0000
                    Re: Sort of trivial code challenge - may be interesting to you anyway Tim Rentsch <tr.17687@z991.linuxsc.com> - 2026-03-06 08:53 -0800
                      Re: Sort of trivial code challenge - may be interesting to you anyway DFS <nospam@dfs.com> - 2026-03-06 19:36 -0500
                        Re: Sort of trivial code challenge - may be interesting to you anyway Tim Rentsch <tr.17687@z991.linuxsc.com> - 2026-03-06 18:14 -0800
                    Re: Sort of trivial code challenge - may be interesting to you anyway Lew Pitcher <lew.pitcher@digitalfreehold.ca> - 2026-03-07 18:21 +0000
                      Re: Sort of trivial code challenge - may be interesting to you anyway Tim Rentsch <tr.17687@z991.linuxsc.com> - 2026-03-07 11:55 -0800
                        Re: Sort of trivial code challenge - may be interesting to you anyway Lew Pitcher <lew.pitcher@digitalfreehold.ca> - 2026-03-07 20:10 +0000
                          Re: Sort of trivial code challenge - may be interesting to you anyway Tim Rentsch <tr.17687@z991.linuxsc.com> - 2026-03-11 10:44 -0700
                    Re: Sort of trivial code challenge - may be interesting to you anyway Tim Rentsch <tr.17687@z991.linuxsc.com> - 2026-03-07 12:02 -0800
                      Re: Sort of trivial code challenge - may be interesting to you anyway Lew Pitcher <lew.pitcher@digitalfreehold.ca> - 2026-03-07 20:14 +0000
                        Re: Sort of trivial code challenge - may be interesting to you anyway Tim Rentsch <tr.17687@z991.linuxsc.com> - 2026-03-11 10:53 -0700
                      Re: Sort of trivial code challenge - may be interesting to you anyway DFS <nospam@dfs.com> - 2026-03-07 16:58 -0500
                        Re: Sort of trivial code challenge - may be interesting to you anyway Michael S <already5chosen@yahoo.com> - 2026-03-08 00:35 +0200
                          Re: Sort of trivial code challenge - may be interesting to you anyway Tim Rentsch <tr.17687@z991.linuxsc.com> - 2026-03-11 08:23 -0700
                        Re: Sort of trivial code challenge - may be interesting to you anyway Janis Papanagnou <janis_papanagnou@hotmail.com> - 2026-03-08 00:40 +0100
                          Re: Sort of trivial code challenge - may be interesting to you anyway DFS <nospam@dfs.com> - 2026-03-08 10:42 -0400
                            Re: Sort of trivial code challenge - may be interesting to you anyway Bart <bc@freeuk.com> - 2026-03-08 15:18 +0000
                              Re: Sort of trivial code challenge - may be interesting to you anyway DFS <nospam@dfs.com> - 2026-03-08 12:21 -0400
                                Re: Sort of trivial code challenge - may be interesting to you anyway Bart <bc@freeuk.com> - 2026-03-08 19:29 +0000
                                  Re: Sort of trivial code challenge - may be interesting to you anyway DFS <nospam@dfs.com> - 2026-03-09 21:20 -0400
                                    Re: Sort of trivial code challenge - may be interesting to you anyway scott@slp53.sl.home (Scott Lurndal) - 2026-03-10 14:43 +0000
                                      Re: Sort of trivial code challenge - may be interesting to you anyway Michael S <already5chosen@yahoo.com> - 2026-03-10 18:08 +0200
                                        Re: Sort of trivial code challenge - may be interesting to you anyway Giovanni <lsodgf0@home.net.it> - 2026-03-10 17:18 +0100
                                        Re: Sort of trivial code challenge - may be interesting to you anyway scott@slp53.sl.home (Scott Lurndal) - 2026-03-10 16:32 +0000
                                      Re: Sort of trivial code challenge - may be interesting to you anyway Keith Thompson <Keith.S.Thompson+u@gmail.com> - 2026-03-10 15:25 -0700
                                        Re: Sort of trivial code challenge - may be interesting to you anyway Tim Rentsch <tr.17687@z991.linuxsc.com> - 2026-03-11 07:07 -0700
                                          Re: Sort of trivial code challenge - may be interesting to you anyway Keith Thompson <Keith.S.Thompson+u@gmail.com> - 2026-03-11 13:49 -0700
                                    Re: Sort of trivial code challenge - may be interesting to you anyway Bart <bc@freeuk.com> - 2026-03-10 20:24 +0000
                                      Re: Sort of trivial code challenge - may be interesting to you anyway Keith Thompson <Keith.S.Thompson+u@gmail.com> - 2026-03-10 15:29 -0700
                                        Re: Sort of trivial code challenge - may be interesting to you anyway Bart <bc@freeuk.com> - 2026-03-11 00:29 +0000
                                        Re: Sort of trivial code challenge - may be interesting to you anyway scott@slp53.sl.home (Scott Lurndal) - 2026-03-11 00:33 +0000
                                          Re: Sort of trivial code challenge - may be interesting to you anyway Bart <bc@freeuk.com> - 2026-03-11 11:04 +0000
                                  Re: Sort of trivial code challenge - may be interesting to you anyway antispam@fricas.org (Waldek Hebisch) - 2026-03-10 20:18 +0000
                                    Re: Sort of trivial code challenge - may be interesting to you anyway Tim Rentsch <tr.17687@z991.linuxsc.com> - 2026-03-12 05:37 -0700
                              Re: Sort of trivial code challenge - may be interesting to you anyway Janis Papanagnou <janis_papanagnou@hotmail.com> - 2026-03-08 17:57 +0100
                              Re: Sort of trivial code challenge - may be interesting to you anyway Keith Thompson <Keith.S.Thompson+u@gmail.com> - 2026-03-08 13:19 -0700
                                Re: Sort of trivial code challenge - may be interesting to you anyway Bart <bc@freeuk.com> - 2026-03-09 01:12 +0000
                              Re: Sort of trivial code challenge - may be interesting to you anyway scott@slp53.sl.home (Scott Lurndal) - 2026-03-08 21:42 +0000
                                Re: Sort of trivial code challenge - may be interesting to you anyway "Chris M. Thomasson" <chris.m.thomasson.1@gmail.com> - 2026-03-08 15:58 -0700
                                  Re: Sort of trivial code challenge - may be interesting to you anyway David Brown <david.brown@hesbynett.no> - 2026-03-09 08:09 +0100
                                    Re: Sort of trivial code challenge - may be interesting to you anyway Janis Papanagnou <janis_papanagnou@hotmail.com> - 2026-03-09 08:53 +0100
                                    Re: Sort of trivial code challenge - may be interesting to you anyway "Chris M. Thomasson" <chris.m.thomasson.1@gmail.com> - 2026-03-09 15:25 -0700
                                Re: Sort of trivial code challenge - may be interesting to you anyway Tim Rentsch <tr.17687@z991.linuxsc.com> - 2026-03-11 14:40 -0700
                              Re: Sort of trivial code challenge - may be interesting to you anyway Tim Rentsch <tr.17687@z991.linuxsc.com> - 2026-03-12 05:55 -0700
                            Re: Sort of trivial code challenge - may be interesting to you anyway Lew Pitcher <lew.pitcher@digitalfreehold.ca> - 2026-03-08 16:00 +0000
                              Re: Sort of trivial code challenge - may be interesting to you anyway Tim Rentsch <tr.17687@z991.linuxsc.com> - 2026-03-11 12:44 -0700
                            Re: Sort of trivial code challenge - may be interesting to you anyway Janis Papanagnou <janis_papanagnou@hotmail.com> - 2026-03-08 17:36 +0100
                            Re: Sort of trivial code challenge - may be interesting to you anyway Keith Thompson <Keith.S.Thompson+u@gmail.com> - 2026-03-08 13:27 -0700
                            Re: Sort of trivial code challenge - may be interesting to you anyway Tim Rentsch <tr.17687@z991.linuxsc.com> - 2026-03-11 06:33 -0700
                        Re: Sort of trivial code challenge - may be interesting to you anyway David Brown <david.brown@hesbynett.no> - 2026-03-08 12:22 +0100
                        Re: Sort of trivial code challenge - may be interesting to you anyway Tim Rentsch <tr.17687@z991.linuxsc.com> - 2026-03-11 06:27 -0700
                      Re: Sort of trivial code challenge - may be interesting to you anyway Keith Thompson <Keith.S.Thompson+u@gmail.com> - 2026-03-07 16:43 -0800
                        Re: Sort of trivial code challenge - may be interesting to you anyway Tim Rentsch <tr.17687@z991.linuxsc.com> - 2026-03-11 07:29 -0700
                          Re: Sort of trivial code challenge - may be interesting to you anyway Keith Thompson <Keith.S.Thompson+u@gmail.com> - 2026-03-11 14:22 -0700
                            Re: Sort of trivial code challenge - may be interesting to you anyway Tim Rentsch <tr.17687@z991.linuxsc.com> - 2026-04-25 10:07 -0700
                              Re: Sort of trivial code challenge - may be interesting to you anyway Keith Thompson <Keith.S.Thompson+u@gmail.com> - 2026-04-25 15:54 -0700
                                Re: Sort of trivial code challenge - may be interesting to you anyway Tim Rentsch <tr.17687@z991.linuxsc.com> - 2026-04-30 03:13 -0700
                Re: Sort of trivial code challenge - may be interesting to you anyway Bart <bc@freeuk.com> - 2026-03-06 16:02 +0000
                  Re: Sort of trivial code challenge - may be interesting to you anyway DFS <nospam@dfs.com> - 2026-03-06 12:11 -0500
                    Re: Sort of trivial code challenge - may be interesting to you anyway DFS <nospam@dfs.com> - 2026-03-06 13:01 -0500
                      Re: Sort of trivial code challenge - may be interesting to you anyway DFS <nospam@dfs.com> - 2026-03-06 13:28 -0500
                    Re: Sort of trivial code challenge - may be interesting to you anyway Bart <bc@freeuk.com> - 2026-03-06 21:53 +0000
                      Re: Sort of trivial code challenge - may be interesting to you anyway DFS <nospam@dfs.com> - 2026-03-06 22:14 -0500
                        Re: Sort of trivial code challenge - may be interesting to you anyway Janis Papanagnou <janis_papanagnou@hotmail.com> - 2026-03-07 07:33 +0100
                          Re: Sort of trivial code challenge - may be interesting to you anyway DFS <nospam@dfs.com> - 2026-03-07 10:24 -0500
                            Re: Sort of trivial code challenge - may be interesting to you anyway Janis Papanagnou <janis_papanagnou@hotmail.com> - 2026-03-07 19:16 +0100
                              Re: Sort of trivial code challenge - may be interesting to you anyway DFS <nospam@dfs.com> - 2026-03-07 14:18 -0500
                                Re: Sort of trivial code challenge - may be interesting to you anyway Janis Papanagnou <janis_papanagnou@hotmail.com> - 2026-03-08 00:47 +0100
                                  Re: Sort of trivial code challenge - may be interesting to you anyway DFS <nospam@dfs.com> - 2026-03-09 22:18 -0400
                                    Re: Sort of trivial code challenge - may be interesting to you anyway Richard Harnden <richard.nospam@gmail.invalid> - 2026-03-10 10:14 +0000
                                    Re: Sort of trivial code challenge - may be interesting to you anyway Richard Harnden <richard.nospam@gmail.invalid> - 2026-03-11 11:40 +0000
                        Re: Sort of trivial code challenge - may be interesting to you anyway Bart <bc@freeuk.com> - 2026-03-07 13:33 +0000
                          Re: Sort of trivial code challenge - may be interesting to you anyway Richard Harnden <richard.nospam@gmail.invalid> - 2026-03-07 14:53 +0000
                            Re: Sort of trivial code challenge - may be interesting to you anyway Bart <bc@freeuk.com> - 2026-03-07 15:44 +0000
                            Re: Sort of trivial code challenge - may be interesting to you anyway Michael S <already5chosen@yahoo.com> - 2026-03-07 19:53 +0200
                          Re: Sort of trivial code challenge - may be interesting to you anyway DFS <nospam@dfs.com> - 2026-03-07 10:22 -0500
                Re: Sort of trivial code challenge - may be interesting to you anyway Bonita Montero <Bonita.Montero@gmail.com> - 2026-03-11 11:40 +0100
                  Re: Sort of trivial code challenge - may be interesting to you anyway DFS <nospam@dfs.com> - 2026-03-11 11:00 -0400
                    Re: Sort of trivial code challenge - may be interesting to you anyway wij <wyniijj5@gmail.com> - 2026-03-12 00:00 +0800
                      Re: Sort of trivial code challenge - may be interesting to you anyway Bonita Montero <Bonita.Montero@gmail.com> - 2026-03-11 18:03 +0100
                        Re: Sort of trivial code challenge - may be interesting to you anyway scott@slp53.sl.home (Scott Lurndal) - 2026-03-11 17:52 +0000
                        Re: Sort of trivial code challenge - may be interesting to you anyway wij <wyniijj5@gmail.com> - 2026-03-12 23:14 +0800
                          Re: Sort of trivial code challenge - may be interesting to you anyway Bonita Montero <Bonita.Montero@gmail.com> - 2026-03-12 16:23 +0100
                          Re: Sort of trivial code challenge - may be interesting to you anyway Keith Thompson <Keith.S.Thompson+u@gmail.com> - 2026-03-12 16:11 -0700
            Re: Sort of trivial code challenge - may be interesting to you anyway Tim Rentsch <tr.17687@z991.linuxsc.com> - 2026-03-05 14:04 -0800
          Re: Sort of trivial code challenge - may be interesting to you anyway Bonita Montero <Bonita.Montero@gmail.com> - 2026-03-11 11:36 +0100
        Re: Sort of trivial code challenge - may be interesting to you anyway Bonita Montero <Bonita.Montero@gmail.com> - 2026-03-11 11:35 +0100
      Re: Sort of trivial code challenge - may be interesting to you anyway Lew Pitcher <lew.pitcher@digitalfreehold.ca> - 2026-03-03 15:40 +0000
        Re: Sort of trivial code challenge - may be interesting to you anyway Tim Rentsch <tr.17687@z991.linuxsc.com> - 2026-03-03 16:23 -0800
          Re: Sort of trivial code challenge - may be interesting to you anyway Lew Pitcher <lew.pitcher@digitalfreehold.ca> - 2026-03-04 15:31 +0000
            Re: Sort of trivial code challenge - may be interesting to you anyway Tim Rentsch <tr.17687@z991.linuxsc.com> - 2026-03-04 09:38 -0800
    Re: Sort of trivial code challenge - may be interesting to you anyway Bonita Montero <Bonita.Montero@gmail.com> - 2026-03-03 16:39 +0100
      Re: Sort of trivial code challenge - may be interesting to you anyway DFS <nospam@dfs.com> - 2026-03-03 12:00 -0500
        Re: Sort of trivial code challenge - may be interesting to you anyway Bonita Montero <Bonita.Montero@gmail.com> - 2026-03-04 11:44 +0100
          Re: Sort of trivial code challenge - may be interesting to you anyway DFS <nospam@dfs.com> - 2026-03-04 17:44 -0500
            Re: Sort of trivial code challenge - may be interesting to you anyway Keith Thompson <Keith.S.Thompson+u@gmail.com> - 2026-03-04 15:13 -0800
              Re: Sort of trivial code challenge - may be interesting to you anyway DFS <nospam@dfs.com> - 2026-03-04 21:07 -0500
            Re: Sort of trivial code challenge - may be interesting to you anyway scott@slp53.sl.home (Scott Lurndal) - 2026-03-04 23:37 +0000
            Re: Sort of trivial code challenge - may be interesting to you anyway Bonita Montero <Bonita.Montero@gmail.com> - 2026-03-05 07:32 +0100
              Re: Sort of trivial code challenge - may be interesting to you anyway Bonita Montero <Bonita.Montero@gmail.com> - 2026-03-05 08:23 +0100
          Re: Sort of trivial code challenge - may be interesting to you anyway DFS <nospam@dfs.com> - 2026-03-05 02:24 -0500
            Re: Sort of trivial code challenge - may be interesting to you anyway Bonita Montero <Bonita.Montero@gmail.com> - 2026-03-05 08:46 +0100
              Re: Sort of trivial code challenge - may be interesting to you anyway Bonita Montero <Bonita.Montero@gmail.com> - 2026-03-05 09:52 +0100
                Re: Sort of trivial code challenge - may be interesting to you anyway tTh <tth@none.invalid> - 2026-03-05 10:49 +0100
                  Re: Sort of trivial code challenge - may be interesting to you anyway Bonita Montero <Bonita.Montero@gmail.com> - 2026-03-05 11:03 +0100
                  Re: Sort of trivial code challenge - may be interesting to you anyway gazelle@shell.xmission.com (Kenny McCormack) - 2026-03-05 15:22 +0000
              Re: Sort of trivial code challenge - may be interesting to you anyway DFS <nospam@dfs.com> - 2026-03-05 05:06 -0500
                Re: Sort of trivial code challenge - may be interesting to you anyway Bonita Montero <Bonita.Montero@gmail.com> - 2026-03-05 11:13 +0100
                  Re: Sort of trivial code challenge - may be interesting to you anyway DFS <nospam@dfs.com> - 2026-03-05 14:11 -0500
                    Re: Sort of trivial code challenge - may be interesting to you anyway Bonita Montero <Bonita.Montero@gmail.com> - 2026-03-06 03:35 +0100
            Re: Sort of trivial code challenge - may be interesting to you anyway scott@slp53.sl.home (Scott Lurndal) - 2026-03-05 14:49 +0000
              Re: Sort of trivial code challenge - may be interesting to you anyway Janis Papanagnou <janis_papanagnou@hotmail.com> - 2026-03-05 19:27 +0100
              Re: Sort of trivial code challenge - may be interesting to you anyway Bonita Montero <Bonita.Montero@gmail.com> - 2026-03-05 19:46 +0100
                Re: Sort of trivial code challenge - may be interesting to you anyway tTh <tth@none.invalid> - 2026-03-05 20:50 +0100
                  Re: Sort of trivial code challenge - may be interesting to you anyway Michael S <already5chosen@yahoo.com> - 2026-03-05 22:34 +0200
                  Re: Sort of trivial code challenge - may be interesting to you anyway Bonita Montero <Bonita.Montero@gmail.com> - 2026-03-06 07:48 +0100
                    Re: Sort of trivial code challenge - may be interesting to you anyway Michael S <already5chosen@yahoo.com> - 2026-03-06 11:49 +0200
                      Re: Sort of trivial code challenge - may be interesting to you anyway Bonita Montero <Bonita.Montero@gmail.com> - 2026-03-06 13:41 +0100
                        Re: Sort of trivial code challenge - may be interesting to you anyway Michael S <already5chosen@yahoo.com> - 2026-03-06 15:33 +0200
                          Re: Sort of trivial code challenge - may be interesting to you anyway Bonita Montero <Bonita.Montero@gmail.com> - 2026-03-06 14:42 +0100
              Re: Sort of trivial code challenge - may be interesting to you anyway Tim Rentsch <tr.17687@z991.linuxsc.com> - 2026-03-05 13:49 -0800
                Re: Sort of trivial code challenge - may be interesting to you anyway scott@slp53.sl.home (Scott Lurndal) - 2026-03-06 02:17 +0000
                  Re: Sort of trivial code challenge - may be interesting to you anyway Tim Rentsch <tr.17687@z991.linuxsc.com> - 2026-03-05 20:06 -0800
                    Re: Sort of trivial code challenge - may be interesting to you anyway scott@slp53.sl.home (Scott Lurndal) - 2026-03-06 14:58 +0000
                      Re: Sort of trivial code challenge - may be interesting to you anyway Michael S <already5chosen@yahoo.com> - 2026-03-06 17:13 +0200
                      Re: Sort of trivial code challenge - may be interesting to you anyway Tim Rentsch <tr.17687@z991.linuxsc.com> - 2026-03-06 08:37 -0800
      Re: Sort of trivial code challenge - may be interesting to you anyway scott@slp53.sl.home (Scott Lurndal) - 2026-03-03 17:29 +0000
        Re: Sort of trivial code challenge - may be interesting to you anyway Bonita Montero <Bonita.Montero@gmail.com> - 2026-03-03 19:20 +0100
      Re: Sort of trivial code challenge - may be interesting to you anyway Tim Rentsch <tr.17687@z991.linuxsc.com> - 2026-03-03 16:26 -0800
        Re: Sort of trivial code challenge - may be interesting to you anyway Bonita Montero <Bonita.Montero@gmail.com> - 2026-03-04 05:27 +0100
    Re: Sort of trivial code challenge - may be interesting to you anyway Opus <ifonly@youknew.org> - 2026-03-04 22:42 +0100
    Re: Sort of trivial code challenge - may be interesting to you anyway peter <peter.noreply@tin.it> - 2026-03-14 10:42 +0100
      Re: Sort of trivial code challenge - may be interesting to you anyway Tim Rentsch <tr.17687@z991.linuxsc.com> - 2026-03-15 15:09 -0700
        Re: Sort of trivial code challenge - may be interesting to you anyway Bonita Montero <Bonita.Montero@gmail.com> - 2026-03-16 09:04 +0100

Page 5 of 11 — ← Prev page 1 … 3 4 [5] 6 7 … 11  Next page →


#396904

FromTim Rentsch <tr.17687@z991.linuxsc.com>
Date2026-03-11 07:57 -0700
Message-ID<86zf4e8lcf.fsf@linuxsc.com>
In reply to#396852
Michael S <already5chosen@yahoo.com> writes:

[concerning implementing integer square root]

> Here is O(log(N)) variant [...]
>
> unsigned usqrt(unsigned x)
> {
>   if (x < 2)
>     return x;
>   unsigned y = x/2, r;
>   while ((r = x / y) < y)
>     y = (r + y) / 2;
>   return y;
> }

Right, O(log(N)).  The initial guess is kind of out in left field so
it takes a while to get into a good zone of convergence.

> And here is variation that is a little less simple, but not
> complicated and faster than one before, because it does fewer
> divisions.  The number of divisions that can't be implemented as
> shift is at most ceil(sqrt(ceil(log2(ceil(sqrt(val)))
>
> unsigned usqrt(unsigned x)
> {
>   if (x < 2)
>     return x;
>   unsigned y = 8, xx = x;
>   while (xx > 63) {
>     xx /= 64;
>     y *= 8;
>   }
>   unsigned r;
>   while ((r = x / y) < y)
>     y = (r + y) / 2;
>   return y;
> }

Here I think your analysis is a little off.  Newton's Method has
quadratic convergence, given an appropriate initial guess.  That
means the second while loop is O(log(# bits)), or O(log(log(N))).

The initial loop, to find a good initial guess, can also be made to
be O(log(log(N)));  exercise for the reader.

The foregoing assumes the usual C operators are O(1), which of
course isn't right as the width of the type involved gets larger,
but that assumption is typically made in this kind of analysis.

(Note: since the width of unsigned int is fixed, technically the
performance of these algorithms is all O(1).  But usually that
condition of constant width is ignored in this sort of discussion.)

> And here is less simple but still obvious implementation that does
> no divisions at all.  No multiplications as well.
>
> unsigned usqrt(unsigned x)
> {
>   if (x < 2)
>     return x;
>   unsigned xx = x;
>   int e = 0;
>   while (xx > 63) {
>     xx /= 64;
>     e += 3;
>   }
>   while (xx > 3) {
>     xx /= 4;
>     e += 1;
>   }
>   unsigned y = 1u << e;
>   x -= y << e;
>   for (e = e - 1; e >= 0; --e) {
>     unsigned d = y*2 + (1u << e);
>     if (d <= (x >> e)) {
>       x -= d << e;
>       y += 1u << e;
>     }
>   }
>   return y;
> }

Here the behavior is linear in the number of bits, or O(log(N)).  At
some point (but not for 32-bit integers) the division method wins
out.

[toc] | [prev] | [next] | [standalone]


#396805

FromLew Pitcher <lew.pitcher@digitalfreehold.ca>
Date2026-03-06 00:12 +0000
Message-ID<10od64s$3qpk6$4@dont-email.me>
In reply to#396795
OK, it's not pretty, but here it is

/*
** From: DFS <nospam@dfs.com>
** Newsgroups: comp.lang.c
** Subject: Sort of trivial code challenge - may be interesting to you anyway
** Date: Thu, 19 Feb 2026 16:55:25 -0500
** Message-ID: <10n80sc$3soe4$1@dont-email.me>
**
** Challenge is to output sequential numbers by column then row:
** Kind of goes without saying the solution should handle any row x column 
** input:
** 
** input rows columns
** --------------------------------------------------------------------
** 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'
** --------------------------------------------------------------------
** 
** * Extra Credit if you determine a formula for this requirement. I kind
**    of brute-forced it with 2 loops.  As you can see, N = prime isn't
**    enough to know if it can be done.
** -----------------------------------------------------------------------
**
** From: Tim Rentsch <tr.17687@z991.linuxsc.com>
** Newsgroups: comp.lang.c
** Subject: Re: Sort of trivial code challenge - may be interesting to you anyway
** Date: Mon, 02 Mar 2026 21:09:21 -0800
** Message-ID: <86ms0peby6.fsf@linuxsc.com>
**
** 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. :)
**
** ==========================================================================
**
** Tim Rentsch counter-counter-challenge; solution by Lew Pitcher 2026-03-05
** cc -o rowcol_TR2 -mtune=native -Wall -std=c99 -pedantic -w rowcol_TR2.c
**
** Note: -w to suppress warnings relating to using switch() to evaluate
**	 a boolean value
**
** This code released into the public domain. Lew Pitcher, 2026-03-04
*/

#include <stdio.h>
#include <stdlib.h>
#include <limits.h>
#include <setjmp.h>
#include <math.h>

/*
** define RIGHT_ALIGN to right-align all numeric results
** otherwise, numeric results will align to the left
*/ 
#ifdef RIGHT_ALIGN
#define FORMAT "%*u"
#else
#define FORMAT "%-*u"
#endif

int main(int argc, char *argv[])
{
  int status = EXIT_FAILURE,
      args_ok = 1;
  unsigned int	n_rows = 0,
		n_cols = 0,
		cut_off = 0;

  switch (argc)
  {
    case 4:	/* rowcol #rows #cols cutoff */
      {
	char *eptr;
	unsigned long int result;
	int valid;

	result = strtoul(argv[3],&eptr,10);
	valid = ((*eptr == 0) && (result <= UINT_MAX));
	cut_off = valid ? result : 0;
	switch (!valid || (cut_off == 0))
	{
	  case 1:
	    fprintf(stderr,"Invalid value for cut-off (\"%s\")\n",argv[3]);
	    args_ok = 0;
	}
      }

    case 3:	/* rowcol #rows #cols */
      {
	char *eptr;
	unsigned long int result;
	int valid;

	result = strtoul(argv[1],&eptr,10);
	valid = ((eptr != argv[1]) && (*eptr == 0) && (result <= UINT_MAX));
	n_rows = valid ? result : 0;
	switch (!valid || (n_rows == 0))
	{
	  case 1:
	    fprintf(stderr,"Invalid value for # rows (\"%s\")\n",argv[1]);
	    args_ok = 0;
	}

	result = strtoul(argv[2],&eptr,10);
	valid = ((eptr != argv[2]) && (*eptr == 0) && (result <= UINT_MAX));
	n_cols = valid ? result : 0;
	switch (!valid || (n_cols == 0))
	{
	  case 1:
	    fprintf(stderr,"Invalid value for # columns (\"%s\")\n",argv[2]);
	    args_ok = 0;
	}
      }

      switch (cut_off)
      {
	case 0:
	  cut_off = n_rows * n_cols;
	  break;

	default:
	  args_ok = (cut_off > n_rows * n_cols) ? fprintf(stderr,"cut off value %u not found in table\n",cut_off), 0 : args_ok;
	  break;
      }

      break;

    case 2:	/* rowcol cutoff */
      {
	char *eptr;
	unsigned long int result;
	int valid;

	result = strtoul(argv[1],&eptr,10);
	valid = ((eptr != argv[1]) && (*eptr == 0) && (result <= UINT_MAX));
	cut_off = valid ? result : 0;

	switch (!valid || (cut_off == 0))
	{
	  case 1:
	    fprintf(stderr,"Invalid value for cut-off (\"%s\")\n",argv[1]);
	    args_ok = 0;

	  case 0:
	    {
	      int valu;
	      jmp_buf CompRoot;

	      valu = setjmp(CompRoot);
	      switch (valu >= cut_off)
	      {
		case 0:
		  ++n_rows;
		  longjmp(CompRoot,(n_rows * n_rows));
		  break;
	      }
	      n_cols = n_rows;
	    }

	    switch ( (cut_off < (n_rows * (n_cols-1)) + 1) )
	    {
	      case 1:
		fprintf(stderr,"Cut off value %u not possible where rows=cols\n",cut_off);
		args_ok = 0;
	    }
	    break;
	}
      }
      break;

    default:
      args_ok = 0;	/* default error msg is usage message */
      break;
  }

  switch (args_ok)
  {
    case 1:
    {
      jmp_buf ByRow, ByCol;
      unsigned int row, col, valu;
      int want_eol;

      cut_off = (cut_off == 0) ? n_rows * n_cols : cut_off ;
      row = setjmp(ByRow);
      want_eol = 0;
      col = setjmp(ByCol);
      valu = 1 + row + (col * n_rows);
      want_eol = (valu <= cut_off) ? printf(FORMAT,1 + snprintf(NULL,0,"%u",cut_off),valu), 1 :want_eol;
      (col + 1 < n_cols) ? longjmp(ByCol,col+1), 1 : 0 ;
      (want_eol) ? putchar('\n') : 0 ;
      (row + 1 < n_rows) ? longjmp(ByRow,row+1), 1 : 0 ;

      status = EXIT_SUCCESS;
    }
    break;

    default:
      fprintf(stderr,"Usage:\t%s #_rows #_cols [ cut-off ]\nor\t%s cut-off\n",argv[0],argv[0]);
  }

  exit(status);
}




-- 
Lew Pitcher
"In Skills We Trust"
Not LLM output - I'm just like this.

[toc] | [prev] | [next] | [standalone]


#396806

FromLew Pitcher <lew.pitcher@digitalfreehold.ca>
Date2026-03-06 00:14 +0000
Message-ID<10od68l$3qpk6$5@dont-email.me>
In reply to#396805
On Fri, 06 Mar 2026 00:12:13 +0000, Lew Pitcher wrote:

> OK, it's not pretty, but here it is
> 
> /*
> ** From: DFS <nospam@dfs.com>
> ** Newsgroups: comp.lang.c
> ** Subject: Sort of trivial code challenge - may be interesting to you anyway
> ** Date: Thu, 19 Feb 2026 16:55:25 -0500
> ** Message-ID: <10n80sc$3soe4$1@dont-email.me>
> **
> ** Challenge is to output sequential numbers by column then row:
> ** Kind of goes without saying the solution should handle any row x column 
> ** input:
> ** 
> ** input rows columns
> ** --------------------------------------------------------------------
> ** 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'
> ** --------------------------------------------------------------------
> ** 
> ** * Extra Credit if you determine a formula for this requirement. I kind
> **    of brute-forced it with 2 loops.  As you can see, N = prime isn't
> **    enough to know if it can be done.
> ** -----------------------------------------------------------------------
> **
> ** From: Tim Rentsch <tr.17687@z991.linuxsc.com>
> ** Newsgroups: comp.lang.c
> ** Subject: Re: Sort of trivial code challenge - may be interesting to you anyway
> ** Date: Mon, 02 Mar 2026 21:09:21 -0800
> ** Message-ID: <86ms0peby6.fsf@linuxsc.com>
> **
> ** 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. :)
> **
> ** ==========================================================================
> **
> ** Tim Rentsch counter-counter-challenge; solution by Lew Pitcher 2026-03-05
> ** cc -o rowcol_TR2 -mtune=native -Wall -std=c99 -pedantic -w rowcol_TR2.c
> **
> ** Note: -w to suppress warnings relating to using switch() to evaluate
> **	 a boolean value
> **
> ** This code released into the public domain. Lew Pitcher, 2026-03-04
> */
> 
> #include <stdio.h>
> #include <stdlib.h>
> #include <limits.h>
> #include <setjmp.h>
> #include <math.h>

Oops... This doesn't use anything from math.h
I forgot to remove it once I got rid of the floatingpoint math functions

-- 
Lew Pitcher
"In Skills We Trust"
Not LLM output - I'm just like this.

[toc] | [prev] | [next] | [standalone]


#396811

FromTim Rentsch <tr.17687@z991.linuxsc.com>
Date2026-03-05 20:31 -0800
Message-ID<86ikb9bmtw.fsf@linuxsc.com>
In reply to#396805
Lew Pitcher <lew.pitcher@digitalfreehold.ca> writes:

> OK, it's not pretty, but here it is

No worries - being pretty is not on the list of requested properties. :)

Congratulations on being the first to post an answer.

Two problems related to how setjmp()/longjmp() are used:

1. Any local variable changed between a setjmp() and the longjmp()
that goes back to it must be declared 'volatile' to avoid problems
with indeterminate values.  (Minor.)

2. A pattern like 'x = setjmp( jbuf );' is not one of the officially
approved forms in the C standard for setjmp().  More specifically,
any such usage has undefined behavior.  (More serious.)

If you look in the C standard for setjmp(), there is a subsection
titled 'Environmental limits' that explains which forms are approved
for use.  Personally I think it's regrettable that 'x = setjmp( jbuf );'
is not one of them, but I feel obliged to observe that limitation and
follow what the standard prescribes for using setjmp().

[toc] | [prev] | [next] | [standalone]


#396818

FromLew Pitcher <lew.pitcher@digitalfreehold.ca>
Date2026-03-06 13:51 +0000
Message-ID<10oem5t$n5hk$1@dont-email.me>
In reply to#396811
On Thu, 05 Mar 2026 20:31:39 -0800, Tim Rentsch wrote:

> Lew Pitcher <lew.pitcher@digitalfreehold.ca> writes:
> 
>> OK, it's not pretty, but here it is
> 
> No worries - being pretty is not on the list of requested properties. :)
> 
> Congratulations on being the first to post an answer.
> 
> Two problems related to how setjmp()/longjmp() are used:
> 
> 1. Any local variable changed between a setjmp() and the longjmp()
> that goes back to it must be declared 'volatile' to avoid problems
> with indeterminate values.  (Minor.)
> 
> 2. A pattern like 'x = setjmp( jbuf );' is not one of the officially
> approved forms in the C standard for setjmp().  More specifically,
> any such usage has undefined behavior.  (More serious.)
> 
> If you look in the C standard for setjmp(), there is a subsection
> titled 'Environmental limits' that explains which forms are approved
> for use.  Personally I think it's regrettable that 'x = setjmp( jbuf );'
> is not one of them, but I feel obliged to observe that limitation and
> follow what the standard prescribes for using setjmp().

yah.

As you can tell, I haven't used setjmp()/longjmp() much, and am
unfamiliar with the caveats surrounding them.

I'll look at revising my code, in the light of your comments, and
repost with a more "legal" version.

Thanks for the observations. I look forward to seeing /your/ code :-)

-- 
Lew Pitcher
"In Skills We Trust"
Not LLM output - I'm just like this.

[toc] | [prev] | [next] | [standalone]


#396827

FromTim Rentsch <tr.17687@z991.linuxsc.com>
Date2026-03-06 08:53 -0800
Message-ID<865x78c322.fsf@linuxsc.com>
In reply to#396818
Lew Pitcher <lew.pitcher@digitalfreehold.ca> writes:

> On Thu, 05 Mar 2026 20:31:39 -0800, Tim Rentsch wrote:
>
>> Lew Pitcher <lew.pitcher@digitalfreehold.ca> writes:
>>
>>> OK, it's not pretty, but here it is
>>
>> No worries - being pretty is not on the list of requested properties. :)
>>
>> Congratulations on being the first to post an answer.
>>
>> Two problems related to how setjmp()/longjmp() are used:
>>
>> 1.  Any local variable changed between a setjmp() and the longjmp()
>> that goes back to it must be declared 'volatile' to avoid problems
>> with indeterminate values.  (Minor.)
>>
>> 2.  A pattern like 'x = setjmp( jbuf );' is not one of the officially
>> approved forms in the C standard for setjmp().  More specifically,
>> any such usage has undefined behavior.  (More serious.)
>>
>> If you look in the C standard for setjmp(), there is a subsection
>> titled 'Environmental limits' that explains which forms are approved
>> for use.  Personally I think it's regrettable that 'x = setjmp( jbuf );'
>> is not one of them, but I feel obliged to observe that limitation and
>> follow what the standard prescribes for using setjmp().
>
> yah.
>
> As you can tell, I haven't used setjmp()/longjmp() much, and am
> unfamiliar with the caveats surrounding them.

I became aware of the restrictions some time ago, after seeing
discussion in comp.lang.c.  After that I looked carefully at the
C standard to learn the official rules.

> I'll look at revising my code, in the light of your comments, and
> repost with a more "legal" version.

Great, I'm cheering you on. :)

> Thanks for the observations.  I look forward to seeing /your/ code :-)

I'm eager to post it.  I'm still hoping DFS will at least post an
attempt.  I'm happy to give a hint if someone asks.  Let's say I
will wait another day or so and can post after that whether or
not DFS has come forward.

[toc] | [prev] | [next] | [standalone]


#396837

FromDFS <nospam@dfs.com>
Date2026-03-06 19:36 -0500
Message-ID<10ofrud$14kd9$1@dont-email.me>
In reply to#396827
On 3/6/2026 11:53 AM, Tim Rentsch wrote:
> Lew Pitcher <lew.pitcher@digitalfreehold.ca> writes:
> 
>> Thanks for the observations.  I look forward to seeing /your/ code :-)
> 
> I'm eager to post it.  

It's time!


> I'm still hoping DFS will at least post an attempt.

You're an optimist.  You'd make a good lion tamer.

"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."

would probably take me 3 days solid to research and write

I did deliver a "no fors, whiles, gotos, or returns" version.

Then I bowed out.

I just want to print to screen some sorted text data by column then row. 
  I should have a new post about it tomorrow.


> I'm happy to give a hint if someone asks.  Let's say I
> will wait another day or so and can post after that whether or
> not DFS has come forward.

Remember what Tom Petty said: "The waiting is the hardest part"

[toc] | [prev] | [next] | [standalone]


#396838

FromTim Rentsch <tr.17687@z991.linuxsc.com>
Date2026-03-06 18:14 -0800
Message-ID<86wlzo9yj7.fsf@linuxsc.com>
In reply to#396837
DFS <nospam@dfs.com> writes:

> On 3/6/2026 11:53 AM, Tim Rentsch wrote:
>
>> Lew Pitcher <lew.pitcher@digitalfreehold.ca> writes:
>>
>>> Thanks for the observations.  I look forward to seeing /your/ code :-)
>>
>> I'm eager to post it.
>
> It's time!
>
>
>> I'm still hoping DFS will at least post an attempt.
>
> You're an optimist.  You'd make a good lion tamer.
>
> "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."
>
> would probably take me 3 days solid to research and write
>
> I did deliver a "no fors, whiles, gotos, or returns" version.
>
> Then I bowed out.

Have you looked up setjmp()/longjmp() yet in the C standard (or
maybe do an online search)?  That could help jog your thinking,
and once you get the main idea things might fall into place
fairly quickly.

I say again that ?: is an important part of the battle here.

Feeling merciful, I am giving one more big hint.  The outline of
my program looks like this

    ...
    ... a few #include's, macros, typedef's, variable declarations
    ...

    static jmp_buf jb;

    int
    main( int argc, char *argv[] ){
        switch(  setjmp( jb )  ){
            ...
            ... (inside the switch there are several 'case' arms)
            ... (however there are no 'break' statements used)
            ...
        }
    }

Obviously some longjmp()'s are needed in the body of the switch() to
make this all work.  Good luck!

[toc] | [prev] | [next] | [standalone]


#396848

FromLew Pitcher <lew.pitcher@digitalfreehold.ca>
Date2026-03-07 18:21 +0000
Message-ID<10ohqc1$1m7c1$3@dont-email.me>
In reply to#396818
On Fri, 06 Mar 2026 13:51:58 +0000, Lew Pitcher wrote:

> On Thu, 05 Mar 2026 20:31:39 -0800, Tim Rentsch wrote:
> 
>> Lew Pitcher <lew.pitcher@digitalfreehold.ca> writes:
>> 
>>> OK, it's not pretty, but here it is
>> 
>> No worries - being pretty is not on the list of requested properties. :)
>> 
>> Congratulations on being the first to post an answer.
>> 
>> Two problems related to how setjmp()/longjmp() are used:
>> 
>> 1. Any local variable changed between a setjmp() and the longjmp()
>> that goes back to it must be declared 'volatile' to avoid problems
>> with indeterminate values.  (Minor.)
>> 
>> 2. A pattern like 'x = setjmp( jbuf );' is not one of the officially
>> approved forms in the C standard for setjmp().  More specifically,
>> any such usage has undefined behavior.  (More serious.)
>> 
>> If you look in the C standard for setjmp(), there is a subsection
>> titled 'Environmental limits' that explains which forms are approved
>> for use.  Personally I think it's regrettable that 'x = setjmp( jbuf );'
>> is not one of them, but I feel obliged to observe that limitation and
>> follow what the standard prescribes for using setjmp().
> 
> yah.
> 
> As you can tell, I haven't used setjmp()/longjmp() much, and am
> unfamiliar with the caveats surrounding them.
> 
> I'll look at revising my code, in the light of your comments, and
> repost with a more "legal" version.

And, here it is

/*
** From: DFS <nospam@dfs.com>
** Newsgroups: comp.lang.c
** Subject: Sort of trivial code challenge - may be interesting to you anyway
** Date: Thu, 19 Feb 2026 16:55:25 -0500
** Message-ID: <10n80sc$3soe4$1@dont-email.me>
**
** Challenge is to output sequential numbers by column then row:
** Kind of goes without saying the solution should handle any row x column 
** input:
** 
** input rows columns
** --------------------------------------------------------------------
** 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'
** --------------------------------------------------------------------
** 
** * Extra Credit if you determine a formula for this requirement. I kind
**    of brute-forced it with 2 loops.  As you can see, N = prime isn't
**    enough to know if it can be done.
** -----------------------------------------------------------------------
**
** From: Tim Rentsch <tr.17687@z991.linuxsc.com>
** Newsgroups: comp.lang.c
** Subject: Re: Sort of trivial code challenge - may be interesting to you anyway
** Date: Mon, 02 Mar 2026 21:09:21 -0800
** Message-ID: <86ms0peby6.fsf@linuxsc.com>
**
** 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. :)
**
** ==========================================================================
**
** Tim Rentsch counter-counter-challenge; solution by Lew Pitcher 2026-03-05
** cc -o rowcol_TR2a -mtune=native -Wall -std=c99 -pedantic -w rowcol_TR2a.c
**
** Note: -w to suppress warnings relating to using switch() to evaluate
**	 a boolean value
**
** This code released into the public domain. Lew Pitcher, 2026-03-07
*/

#include <stdio.h>
#include <stdlib.h>
#include <limits.h>
#include <setjmp.h>

/*
** define RIGHT_ALIGN to right-align all numeric results
** otherwise, numeric results will align to the left
*/ 
#ifdef RIGHT_ALIGN
#define FORMAT "%*u"
#else
#define FORMAT "%-*u"
#endif

int main(int argc, char *argv[])
{
  int status = EXIT_FAILURE,
      args_ok = 1;
  unsigned int	n_rows = 0,
		n_cols = 0,
		cut_off = 0;

  switch (argc)
  {
    case 4:	/* rowcol #rows #cols cutoff */
      {
	char *eptr;
	unsigned long int result;
	int valid;

	result = strtoul(argv[3],&eptr,10);
	valid = ((*eptr == 0) && (result <= UINT_MAX));
	cut_off = valid ? result : 0;
	switch (!valid || (cut_off == 0))
	{
	  case 1:
	    fprintf(stderr,"Invalid value for cut-off (\"%s\")\n",argv[3]);
	    args_ok = 0;
	}
      }

    case 3:	/* rowcol #rows #cols */
      {
	char *eptr;
	unsigned long int result;
	int valid;

	result = strtoul(argv[1],&eptr,10);
	valid = ((eptr != argv[1]) && (*eptr == 0) && (result <= UINT_MAX));
	n_rows = valid ? result : 0;
	switch (!valid || (n_rows == 0))
	{
	  case 1:
	    fprintf(stderr,"Invalid value for # rows (\"%s\")\n",argv[1]);
	    args_ok = 0;
	}

	result = strtoul(argv[2],&eptr,10);
	valid = ((eptr != argv[2]) && (*eptr == 0) && (result <= UINT_MAX));
	n_cols = valid ? result : 0;
	switch (!valid || (n_cols == 0))
	{
	  case 1:
	    fprintf(stderr,"Invalid value for # columns (\"%s\")\n",argv[2]);
	    args_ok = 0;
	}
      }

      switch (cut_off)
      {
	case 0:
	  cut_off = n_rows * n_cols;
	  break;

	default:
	  args_ok = (cut_off > n_rows * n_cols) ? fprintf(stderr,"cut off value %u not found in table\n",cut_off), 0 : args_ok;
	  break;
      }

      break;

    case 2:	/* rowcol cutoff */
      {
	char *eptr;
	unsigned long int result;
	int valid;

	result = strtoul(argv[1],&eptr,10);
	valid = ((eptr != argv[1]) && (*eptr == 0) && (result <= UINT_MAX));
	cut_off = valid ? result : 0;

	switch (!valid || (cut_off == 0))
	{
	  case 1:
	    fprintf(stderr,"Invalid value for cut-off (\"%s\")\n",argv[1]);
	    args_ok = 0;

	  case 0:
	    {
	      static jmp_buf LocalState;	/* work variable; static storage with block scope */
	      static unsigned int num_rows = 0;	/* work variable; static storage with block scope */

	      switch (setjmp(LocalState) >= cut_off)
	      {
		case 0:
		  ++num_rows;
		  longjmp(LocalState,(num_rows * num_rows));
	      }
	      n_cols = n_rows = num_rows;
	    }

	    switch ( (cut_off < (n_rows * (n_cols-1)) + 1) )
	    {
	      case 1:
		fprintf(stderr,"Cut off value %u not possible where rows=cols\n",cut_off);
		args_ok = 0;
	    }
	    break;
	}
      }
      break;

    default:
      args_ok = 0;	/* default error msg is usage message */
      break;
  }

  switch (args_ok)
  {
    case 1:
    {
      static jmp_buf LocalState;	/* work variable; static storage with block scope */
      static unsigned int count = 0,	/* work variable; static storage with block scope */
			  want_eol = 0;	/* work variable; static storage with block scope */

      switch (setjmp(LocalState) < (n_rows * n_cols))
      {
	case 1:
	  {
	    static unsigned int row, col, valu;	/* work variables; static storage with block scope */

	    row = count / n_cols;
	    col = count % n_cols;
	    want_eol = (col == 0) ? 0 : want_eol;
	    valu = 1  + row + (col * n_rows);
	    want_eol = (valu <= cut_off) ? printf(FORMAT,1 + snprintf(NULL,0,"%u",cut_off),valu), 1: want_eol;
	    ((col == n_cols - 1) && (want_eol)) ? putchar('\n') : 0;
	    ++count; longjmp(LocalState,count);
	  }
      }

      status = EXIT_SUCCESS;
    }
    break;

    default:
      fprintf(stderr,"Usage:\t%s #_rows #_cols [ cut-off ]\nor\t%s cut-off\n",argv[0],argv[0]);
  }

  exit(status);
}

-- 
Lew Pitcher
"In Skills We Trust"
Not LLM output - I'm just like this.

[toc] | [prev] | [next] | [standalone]


#396850

FromTim Rentsch <tr.17687@z991.linuxsc.com>
Date2026-03-07 11:55 -0800
Message-ID<86seab9zz2.fsf@linuxsc.com>
In reply to#396848
Lew Pitcher <lew.pitcher@digitalfreehold.ca> writes:

> On Fri, 06 Mar 2026 13:51:58 +0000, Lew Pitcher wrote:
>
[...]

>> I'll look at revising my code, in the light of your comments, and
>> repost with a more "legal" version.
>
> And, here it is
> [...]

First of two responses

1. I think your error checking is more thorough than what I did.
I do check that inputs are well formed but it's possible that
out of range values will give inappropriate results.

2. I don't have any error return.  I do diagnose various conditions
(and in particular the no-square-possible cutoff values) but don't
bother with status.  It would be easy to add but I didn't do it. :)

3. How setjmp() is used is still out of bounds.  The rule for setjmp()
in a switch() is the setjmp() must be the entire expression that is
switched on.  Effectively longjmp() can pass only constant values,
because there is no way to do anything with the value except see if
it is true or false (in an if()) or match it against 'case' labels.

My code in the next followup.

[toc] | [prev] | [next] | [standalone]


#396853

FromLew Pitcher <lew.pitcher@digitalfreehold.ca>
Date2026-03-07 20:10 +0000
Message-ID<10oi0n0$1m7c1$4@dont-email.me>
In reply to#396850
On Sat, 07 Mar 2026 11:55:13 -0800, Tim Rentsch wrote:

> Lew Pitcher <lew.pitcher@digitalfreehold.ca> writes:
> 
>> On Fri, 06 Mar 2026 13:51:58 +0000, Lew Pitcher wrote:
>>
> [...]
> 
>>> I'll look at revising my code, in the light of your comments, and
>>> repost with a more "legal" version.
>>
>> And, here it is
>> [...]
> 
> First of two responses
> 
> 1. I think your error checking is more thorough than what I did.
> I do check that inputs are well formed but it's possible that
> out of range values will give inappropriate results.
> 
> 2. I don't have any error return.  I do diagnose various conditions
> (and in particular the no-square-possible cutoff values) but don't
> bother with status.  It would be easy to add but I didn't do it. :)
> 
> 3. How setjmp() is used is still out of bounds.  The rule for setjmp()
> in a switch() is the setjmp() must be the entire expression that is
> switched on.  Effectively longjmp() can pass only constant values,
> because there is no way to do anything with the value except see if
> it is true or false (in an if()) or match it against 'case' labels.

You (and the standards) are a hard task-master :-)

Corrected version follows

/*
** From: DFS <nospam@dfs.com>
** Newsgroups: comp.lang.c
** Subject: Sort of trivial code challenge - may be interesting to you anyway
** Date: Thu, 19 Feb 2026 16:55:25 -0500
** Message-ID: <10n80sc$3soe4$1@dont-email.me>
**
** Challenge is to output sequential numbers by column then row:
** Kind of goes without saying the solution should handle any row x column 
** input:
** 
** input rows columns
** --------------------------------------------------------------------
** 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'
** --------------------------------------------------------------------
** 
** * Extra Credit if you determine a formula for this requirement. I kind
**    of brute-forced it with 2 loops.  As you can see, N = prime isn't
**    enough to know if it can be done.
** -----------------------------------------------------------------------
**
** From: Tim Rentsch <tr.17687@z991.linuxsc.com>
** Newsgroups: comp.lang.c
** Subject: Re: Sort of trivial code challenge - may be interesting to you anyway
** Date: Mon, 02 Mar 2026 21:09:21 -0800
** Message-ID: <86ms0peby6.fsf@linuxsc.com>
**
** 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. :)
**
** ==========================================================================
**
** Tim Rentsch counter-counter-challenge; solution by Lew Pitcher 2026-03-05
** cc -o rowcol_TR2a -mtune=native -Wall -std=c99 -pedantic -w rowcol_TR2a.c
**
** Note: -w to suppress warnings relating to using switch() to evaluate
**	 a boolean value
**
** This code released into the public domain. Lew Pitcher, 2026-03-07
*/

#include <stdio.h>
#include <stdlib.h>
#include <limits.h>
#include <setjmp.h>

/*
** define RIGHT_ALIGN to right-align all numeric results
** otherwise, numeric results will align to the left
*/ 
#ifdef RIGHT_ALIGN
#define FORMAT "%*u"
#else
#define FORMAT "%-*u"
#endif

int main(int argc, char *argv[])
{
  int status = EXIT_FAILURE,
      args_ok = 1;
  unsigned int	n_rows = 0,
		n_cols = 0,
		cut_off = 0;

  switch (argc)
  {
    case 4:	/* rowcol #rows #cols cutoff */
      {
	char *eptr;
	unsigned long int result;
	int valid;

	result = strtoul(argv[3],&eptr,10);
	valid = ((*eptr == 0) && (result <= UINT_MAX));
	cut_off = valid ? result : 0;
	switch (!valid || (cut_off == 0))
	{
	  case 1:
	    fprintf(stderr,"Invalid value for cut-off (\"%s\")\n",argv[3]);
	    args_ok = 0;
	}
      }

    case 3:	/* rowcol #rows #cols */
      {
	char *eptr;
	unsigned long int result;
	int valid;

	result = strtoul(argv[1],&eptr,10);
	valid = ((eptr != argv[1]) && (*eptr == 0) && (result <= UINT_MAX));
	n_rows = valid ? result : 0;
	switch (!valid || (n_rows == 0))
	{
	  case 1:
	    fprintf(stderr,"Invalid value for # rows (\"%s\")\n",argv[1]);
	    args_ok = 0;
	}

	result = strtoul(argv[2],&eptr,10);
	valid = ((eptr != argv[2]) && (*eptr == 0) && (result <= UINT_MAX));
	n_cols = valid ? result : 0;
	switch (!valid || (n_cols == 0))
	{
	  case 1:
	    fprintf(stderr,"Invalid value for # columns (\"%s\")\n",argv[2]);
	    args_ok = 0;
	}
      }

      switch (cut_off)
      {
	case 0:
	  cut_off = n_rows * n_cols;
	  break;

	default:
	  args_ok = (cut_off > n_rows * n_cols) ? fprintf(stderr,"cut off value %u not found in table\n",cut_off), 0 : args_ok;
	  break;
      }

      break;

    case 2:	/* rowcol cutoff */
      {
	char *eptr;
	unsigned long int result;
	int valid;

	result = strtoul(argv[1],&eptr,10);
	valid = ((eptr != argv[1]) && (*eptr == 0) && (result <= UINT_MAX));
	cut_off = valid ? result : 0;

	switch (!valid || (cut_off == 0))
	{
	  case 1:
	    fprintf(stderr,"Invalid value for cut-off (\"%s\")\n",argv[1]);
	    args_ok = 0;

	  case 0:
	    {
	      static jmp_buf LocalState;	/* work variable; static storage with block scope */
	      static unsigned int num_rows = 0;	/* work variable; static storage with block scope */

	      switch (setjmp(LocalState))
	      {
		case 0:	/* initial setjmp(), will always be false */
		case 1:	/* false value from longjmp() */
		  ++num_rows;
		  longjmp(LocalState,1 + ((num_rows * num_rows) >= cut_off));	/* false == 1, true == 2 */
	      }
	      n_cols = n_rows = num_rows;
	    }

	    switch ( (cut_off < (n_rows * (n_cols-1)) + 1) )
	    {
	      case 1:
		fprintf(stderr,"Cut off value %u not possible where rows=cols\n",cut_off);
		args_ok = 0;
	    }
	    break;
	}
      }
      break;

    default:
      args_ok = 0;	/* default error msg is usage message */
      break;
  }

  switch (args_ok)
  {
    case 1:
    {
      static jmp_buf LocalState;	/* work variable; static storage with block scope */
      static unsigned int count = 0,	/* work variable; static storage with block scope */
			  want_eol = 0;	/* work variable; static storage with block scope */

      switch (setjmp(LocalState))
      {
	case 0:	/* initial value from setjmp() */
	case 2: /* true value from longjmp() */
	  {
	    static unsigned int row, col, valu;	/* work variables; static storage with block scope */

	    row = count / n_cols;
	    col = count % n_cols;
	    want_eol = (col == 0) ? 0 : want_eol;
	    valu = 1  + row + (col * n_rows);
	    want_eol = (valu <= cut_off) ? printf(FORMAT,1 + snprintf(NULL,0,"%u",cut_off),valu), 1: want_eol;
	    ((col == n_cols - 1) && (want_eol)) ? putchar('\n') : 0;
	    ++count; longjmp(LocalState,1 + (count < (n_rows * n_cols)));	/* false == 1, true == 2 */
	  }
      }

      status = EXIT_SUCCESS;
    }
    break;

    default:
      fprintf(stderr,"Usage:\t%s #_rows #_cols [ cut-off ]\nor\t%s cut-off\n",argv[0],argv[0]);
  }

  exit(status);
}




> My code in the next followup.




-- 
Lew Pitcher
"In Skills We Trust"
Not LLM output - I'm just like this.

[toc] | [prev] | [next] | [standalone]


#396909

FromTim Rentsch <tr.17687@z991.linuxsc.com>
Date2026-03-11 10:44 -0700
Message-ID<86qzpq8dm5.fsf@linuxsc.com>
In reply to#396853
Lew Pitcher <lew.pitcher@digitalfreehold.ca> writes:

> On Sat, 07 Mar 2026 11:55:13 -0800, Tim Rentsch wrote:
>
>> Lew Pitcher <lew.pitcher@digitalfreehold.ca> writes:
>>
>>> On Fri, 06 Mar 2026 13:51:58 +0000, Lew Pitcher wrote:
>>
>> [...]
>>
>>>> I'll look at revising my code, in the light of your comments, and
>>>> repost with a more "legal" version.
>>>
>>> And, here it is
>>> [...]
>>
>> First of two responses
>>
>> 1.  I think your error checking is more thorough than what I did.
>> I do check that inputs are well formed but it's possible that
>> out of range values will give inappropriate results.
>>
>> 2.  I don't have any error return.  I do diagnose various conditions
>> (and in particular the no-square-possible cutoff values) but don't
>> bother with status.  It would be easy to add but I didn't do it. :)
>>
>> 3.  How setjmp() is used is still out of bounds.  The rule for setjmp()
>> in a switch() is the setjmp() must be the entire expression that is
>> switched on.  Effectively longjmp() can pass only constant values,
>> because there is no way to do anything with the value except see if
>> it is true or false (in an if()) or match it against 'case' labels.
>
> You (and the standards) are a hard task-master :-)

The C standard does need an attention to detail in many cases.
Personally I think that is a plus as well as being a minus in
some ways - being forced to pay attention to detail often helps
clarify my thinking.

> Corrected version follows
>
[...]

I appreciate the effort.  I was surprised by the use of
setjmp() to simulate loops;  probably I shouldn't have
been but it hadn't occurred to me before now.  Then again
I have been used to functional programming techniques for
more than 20 years now so loops feel less natural to me
now than they used to.

One point that confused me for a while was the lack of a
'break' before the initial 'case 3:'.  At first I thought
it was just an oversight that it wasn't there.  Of course
it was deliberate, and I saw what you were doing.  My code
accepts and allows a cutoff of 0, which may have added to
my confusion.  Your code could do that by using a different
value for the "no cutoff entered" condition.

I may have other general comments later.

[toc] | [prev] | [next] | [standalone]


#396851

FromTim Rentsch <tr.17687@z991.linuxsc.com>
Date2026-03-07 12:02 -0800
Message-ID<86o6kz9zng.fsf@linuxsc.com>
In reply to#396818
Lew Pitcher <lew.pitcher@digitalfreehold.ca> writes:

> [...] I look forward to seeing /your/ code :-)

Here we go...

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <setjmp.h>

typedef size_t  Z;
typedef _Bool   B;

static  Z       k,  h,  w,  c;
static  int     d;
static  jmp_buf jb;

#define GO(x)         longjmp( jb, x )
#define NUMBERISH(p)  ((p) && *(p) && (p)[ strspn((p),"0123456789") ] == 0)

enum {
  START,         // the initial state; must be zero
    AFU, USAGE,  // give suitable message and exit
    ROOT, DRAT,  // find ceiling( sqrt( cutoff ) ); possible no joy exit
    HWC,         // display H*W values with cutoff C
  FIN,           // exit program
};

int
main( int argc, char *argv[] ){
 switch(  setjmp( jb )  ){
  case START: {
     B usage   =  argc < 2 || argc > 4;

     B g1      =  argc > 1  &&  NUMBERISH( argv[1] );
     B g2      =  argc > 2  &&  NUMBERISH( argv[2] );
     B g3      =  argc > 3  &&  NUMBERISH( argv[3] );

     Z a1      =  g1 ? strtoul( argv[1], 0, 10 ) : 0;
     Z a2      =  g2 ? strtoul( argv[2], 0, 10 ) : 0;
     Z a3      =  g3 ? strtoul( argv[3], 0, 10 ) : 0;

     B square  =  argc == 2 &&  g1;
     B hw      =  argc == 3 &&  g1&&g2 && a1&&a2;
     B hwc     =  argc == 4 &&  g1&&g2 && a1&&a2 && g3;

     k = 0;
     h = hw || hwc ? a1  :  a1/4 + !a1;  // note: initial value(h) > 0
     w = hw || hwc ? a2  :  h;
     c = square ? a1  :  !hwc ? h*w  :  a3 > h*w ? h*w  :  a3;
     d = snprintf( 0, 0, "%zu", c );

     GO( usage ?USAGE : square ?ROOT : (hw||hwc) && a1&&a2 ?HWC : AFU );
  }

  case AFU:
     printf( " urk... bad arguments\n" );
     GO( USAGE );

  case USAGE:
     printf( " usage:\n" );
     printf( "     %s cutoff  {{for square}}\n", argv[0] );
     printf( "     %s rows columns [cutoff]\n",  argv[0] );
     GO( FIN );

  case ROOT: {
     h =  c < 2 ? 1  :  c < 5 ? 2  :  (h + c/h) / 2;
     h += h*h < c;
     w = h;
     B done  =  c < 2  ||  h*h < c+2*h && c <= h*h;
     B good  =  c < 2  ||  h*h < c+h   && c <= h*h;
     GO(  !done ?ROOT  :  good ?HWC  :  DRAT  );
  }

  case DRAT:
     printf( " square with cutoff %zu - no joy\n", c );
     GO( FIN );

  case HWC: {
     B eol    =  k/h + 1 == w;
     B end    =  k+1 + (h>c ? h-c : 0) >= h*w;
     Z nextk  =  eol ? k - (w-1)*h + 1 : k+h;

     printf(  k < c        ? " %*zu" : "",  d,  k+1 );
     printf(  c > 0 && eol ? "\n"    : ""           );

     GO(  end ?(printf( "------\n" ), FIN)  :  (k = nextk, HWC)  );
  }
 }
}

[toc] | [prev] | [next] | [standalone]


#396854

FromLew Pitcher <lew.pitcher@digitalfreehold.ca>
Date2026-03-07 20:14 +0000
Message-ID<10oi0un$1m7c1$5@dont-email.me>
In reply to#396851
On Sat, 07 Mar 2026 12:02:11 -0800, Tim Rentsch wrote:

> Lew Pitcher <lew.pitcher@digitalfreehold.ca> writes:
> 
>> [...] I look forward to seeing /your/ code :-)
> 
> Here we go...
[snip]

Brilliant!
I bow to the master. I obviously have a lot to learn

Thank you, I've learned something new today.
-- 
Lew Pitcher
"In Skills We Trust"
Not LLM output - I'm just like this.

[toc] | [prev] | [next] | [standalone]


#396911

FromTim Rentsch <tr.17687@z991.linuxsc.com>
Date2026-03-11 10:53 -0700
Message-ID<86ms0e8d7x.fsf@linuxsc.com>
In reply to#396854
Lew Pitcher <lew.pitcher@digitalfreehold.ca> writes:

> On Sat, 07 Mar 2026 12:02:11 -0800, Tim Rentsch wrote:
>
>> Lew Pitcher <lew.pitcher@digitalfreehold.ca> writes:
>>
>>> [...] I look forward to seeing /your/ code :-)
>>
>> Here we go...
>
> [snip]
>
> Brilliant!
> I bow to the master.

Thank you, it's nice to be appreciated.

> I obviously have a lot to learn
>
> Thank you, I've learned something new today.

I am glad to hear that.  I expect you will have no
trouble discerning and absorbing the novel patterns
you see in my code example.

[toc] | [prev] | [next] | [standalone]


#396855

FromDFS <nospam@dfs.com>
Date2026-03-07 16:58 -0500
Message-ID<10oi72k$1rss6$1@dont-email.me>
In reply to#396851
On 3/7/2026 3:02 PM, Tim Rentsch wrote:
> Lew Pitcher <lew.pitcher@digitalfreehold.ca> writes:
> 
>> [...] I look forward to seeing /your/ code :-)
> 
> Here we go...


OMG!  Congrats on an innovative piece of C code.  Never seen anything 
like it.

I don't understand everything yet, but nested ternaries aside, it's 
pretty easy to follow too.

A nit you may have forgotten: you earlier said main() was not allowed:

"not mentioning main() was an oversight on my part.
(Still not okay to call it.)"

I saw David Brown offered about 5 ways to bypass main().


Also I have a 'challenge' to add to your program - that I already added 
to mine - to make it even more compelling:

* when looking for a square matrix, instead of printing 'no joy' print
   out a matrix that will visually demonstrate why the number doesn't fit
   in a square matrix.

For instance:

./rc-dfs 17
  square matrix for 1-17 not possible
   --------------------
    1   2   3   4   5
   --------------------
    1   6  11  16
    2   7  12  17
    3   8  13
    4   9  14
    5  10  15

If you get stuck, I'll give you a hint :)




> #include <stdio.h>
> #include <stdlib.h>
> #include <string.h>
> #include <setjmp.h>
> 
> typedef size_t  Z;
> typedef _Bool   B;
> 
> static  Z       k,  h,  w,  c;
> static  int     d;
> static  jmp_buf jb;
> 
> #define GO(x)         longjmp( jb, x )
> #define NUMBERISH(p)  ((p) && *(p) && (p)[ strspn((p),"0123456789") ] == 0)
> 
> enum {
>    START,         // the initial state; must be zero
>      AFU, USAGE,  // give suitable message and exit
>      ROOT, DRAT,  // find ceiling( sqrt( cutoff ) ); possible no joy exit
>      HWC,         // display H*W values with cutoff C
>    FIN,           // exit program
> };
> 
> int
> main( int argc, char *argv[] ){
>   switch(  setjmp( jb )  ){
>    case START: {
>       B usage   =  argc < 2 || argc > 4;
> 
>       B g1      =  argc > 1  &&  NUMBERISH( argv[1] );
>       B g2      =  argc > 2  &&  NUMBERISH( argv[2] );
>       B g3      =  argc > 3  &&  NUMBERISH( argv[3] );
> 
>       Z a1      =  g1 ? strtoul( argv[1], 0, 10 ) : 0;
>       Z a2      =  g2 ? strtoul( argv[2], 0, 10 ) : 0;
>       Z a3      =  g3 ? strtoul( argv[3], 0, 10 ) : 0;
> 
>       B square  =  argc == 2 &&  g1;
>       B hw      =  argc == 3 &&  g1&&g2 && a1&&a2;
>       B hwc     =  argc == 4 &&  g1&&g2 && a1&&a2 && g3;
> 
>       k = 0;
>       h = hw || hwc ? a1  :  a1/4 + !a1;  // note: initial value(h) > 0
>       w = hw || hwc ? a2  :  h;
>       c = square ? a1  :  !hwc ? h*w  :  a3 > h*w ? h*w  :  a3;
>       d = snprintf( 0, 0, "%zu", c );
> 
>       GO( usage ?USAGE : square ?ROOT : (hw||hwc) && a1&&a2 ?HWC : AFU );
>    }
> 
>    case AFU:
>       printf( " urk... bad arguments\n" );
>       GO( USAGE );
> 
>    case USAGE:
>       printf( " usage:\n" );
>       printf( "     %s cutoff  {{for square}}\n", argv[0] );
>       printf( "     %s rows columns [cutoff]\n",  argv[0] );
>       GO( FIN );
> 
>    case ROOT: {
>       h =  c < 2 ? 1  :  c < 5 ? 2  :  (h + c/h) / 2;
>       h += h*h < c;
>       w = h;
>       B done  =  c < 2  ||  h*h < c+2*h && c <= h*h;
>       B good  =  c < 2  ||  h*h < c+h   && c <= h*h;
>       GO(  !done ?ROOT  :  good ?HWC  :  DRAT  );
>    }
> 
>    case DRAT:
>       printf( " square with cutoff %zu - no joy\n", c );
>       GO( FIN );
> 
>    case HWC: {
>       B eol    =  k/h + 1 == w;
>       B end    =  k+1 + (h>c ? h-c : 0) >= h*w;
>       Z nextk  =  eol ? k - (w-1)*h + 1 : k+h;
> 
>       printf(  k < c        ? " %*zu" : "",  d,  k+1 );
>       printf(  c > 0 && eol ? "\n"    : ""           );
> 
>       GO(  end ?(printf( "------\n" ), FIN)  :  (k = nextk, HWC)  );
>    }
>   }
> }


I'm gonna try and borrow some techniques from this banger, if I think 
they're appropriate.

What do you think would be the reaction in a corporate programming dept 
to this unique kind of code?

[toc] | [prev] | [next] | [standalone]


#396856

FromMichael S <already5chosen@yahoo.com>
Date2026-03-08 00:35 +0200
Message-ID<20260308003557.00000754@yahoo.com>
In reply to#396855
On Sat, 7 Mar 2026 16:58:48 -0500
DFS <nospam@dfs.com> wrote:

> 
> A nit you may have forgotten: you earlier said main() was not allowed:
> 

You misunderstood.
Having main() is allowed and necessary. Calling main() in your code is
forbidden.
If calling main() recursively was allowed then possible solution could
be just uglier than previos counter-challenge, but would not require
any different ideas.

[toc] | [prev] | [next] | [standalone]


#396906

FromTim Rentsch <tr.17687@z991.linuxsc.com>
Date2026-03-11 08:23 -0700
Message-ID<86v7f28k67.fsf@linuxsc.com>
In reply to#396856
Michael S <already5chosen@yahoo.com> writes:

> On Sat, 7 Mar 2026 16:58:48 -0500
> DFS <nospam@dfs.com> wrote:
>
>> A nit you may have forgotten:  you earlier said main() was not allowed:
>
> You misunderstood.
> Having main() is allowed and necessary.  Calling main() in your code is
> forbidden.

Right.

> If calling main() recursively was allowed then possible solution could
> be just uglier than previos counter-challenge, but would not require
> any different ideas.

It may not require different ideas, but IMO it benefits from
adopting an approach similar to the posted setjmp version.  Here
is a revision of the code I posted, changed so that it does not
use setjmp()/longjmp() but instead calls main() recursively.  I
think using recursive calls to main to simulate having multiple
functions would make the code more difficult to understand, not
easier.

Note by the way that all calls to main() below are tail calls,
and are optimized away, so there is no stack depth penalty for
this method, unlike using recursive calls to main to simulate
having other functions available.


#include <stdio.h>
#include <stdlib.h>
#include <string.h>

typedef size_t  Z;
typedef _Bool   B;

static  Z       k,  h,  w,  c;
static  int     d;

#define GO(x)         return  main( (x), argv )
#define NUMBERISH(p)  ((p) && *(p) && (p)[ strspn((p),"0123456789") ] == 0)

enum {
  START,         // the initial state; must be zero
    NADA = -99,  // make the following values all be negative
    AFU, USAGE,  // give suitable message and exit
    ROOT, DRAT,  // find ceiling( sqrt( cutoff ) ); possible no joy exit
    HWC,         // display H*W values with cutoff C
  FIN,           // exit program
};

int
main( int argc, char *argv[] ){
 switch(  argc < 0 ? argc : 0  ){
  case START: {
     B usage   =  argc < 2 || argc > 4;

     B g1      =  argc > 1  &&  NUMBERISH( argv[1] );
     B g2      =  argc > 2  &&  NUMBERISH( argv[2] );
     B g3      =  argc > 3  &&  NUMBERISH( argv[3] );

     Z a1      =  g1 ? strtoul( argv[1], 0, 10 ) : 0;
     Z a2      =  g2 ? strtoul( argv[2], 0, 10 ) : 0;
     Z a3      =  g3 ? strtoul( argv[3], 0, 10 ) : 0;

     B square  =  argc == 2 &&  g1;
     B hw      =  argc == 3 &&  g1&&g2 && a1&&a2;
     B hwc     =  argc == 4 &&  g1&&g2 && a1&&a2 && g3;

     k = 0;
     h = hw || hwc ? a1  :  a1/4 + !a1;  // note: initial value(h) > 0
     w = hw || hwc ? a2  :  h;
     c = square ? a1  :  !hwc ? h*w  :  a3 > h*w ? h*w  :  a3;
     d = snprintf( 0, 0, "%zu", c );

     GO( usage ?USAGE : square ?ROOT : (hw||hwc) && a1&&a2 ?HWC : AFU );
  }

  case AFU:
     printf( " urk... bad arguments\n" );
     GO( USAGE );

  case USAGE:
     printf( " usage:\n" );
     printf( "     %s cutoff  {{for square}}\n", argv[0] );
     printf( "     %s rows columns [cutoff]\n",  argv[0] );
     GO( FIN );

  case ROOT: {
     h =  c < 2 ? 1  :  c < 5 ? 2  :  (h + c/h) / 2;
     h += h*h < c;
     w = h;
     B done  =  c < 2  ||  h*h < c+2*h && c <= h*h;
     B good  =  c < 2  ||  h*h < c+h   && c <= h*h;
     GO(  !done ?ROOT  :  good ?HWC  :  DRAT  );
  }

  case DRAT:
     printf( " square with cutoff %zu - no joy\n", c );
     GO( FIN );

  case HWC: {
     B eol    =  k/h + 1 == w;
     B end    =  k+1 + (h>c ? h-c : 0) >= h*w;
     Z nextk  =  eol ? k - (w-1)*h + 1 : k+h;

     printf(  k < c        ? " %*zu" : "",  d,  k+1 );
     printf(  c > 0 && eol ? "\n"    : ""           );

     GO(  end ?(printf( "------\n" ), FIN)  :  (k = nextk, HWC)  );
  }
 }
}

[toc] | [prev] | [next] | [standalone]


#396858

FromJanis Papanagnou <janis_papanagnou@hotmail.com>
Date2026-03-08 00:40 +0100
Message-ID<10oid0u$1u9aa$2@dont-email.me>
In reply to#396855
On 07.03.26 22:58, DFS wrote:
> On 3/7/2026 3:02 PM, Tim Rentsch wrote:
>> [...]
> 
> What do you think would be the reaction in a corporate programming dept 
> to this unique kind of code?

 From my experiences in a couple such departments of professional
software development...

The "uniqueness" would not be a problem. It would have failed to
many requirements that maintainable code was expected to have.

I can explain the (positive) excitement only by some nerdy stance
in this specific CLC domain.

Janis

[toc] | [prev] | [next] | [standalone]


#396864

FromDFS <nospam@dfs.com>
Date2026-03-08 10:42 -0400
Message-ID<10ok1sl$2e7mc$1@dont-email.me>
In reply to#396858
On 3/7/2026 6:40 PM, Janis Papanagnou wrote:
> On 07.03.26 22:58, DFS wrote:
>> On 3/7/2026 3:02 PM, Tim Rentsch wrote:
>>> [...]
>>
>> What do you think would be the reaction in a corporate programming 
>> dept to this unique kind of code?
> 
> From my experiences in a couple such departments of professional
> software development...
> 
> The "uniqueness" would not be a problem. It would have failed to
> many requirements that maintainable code was expected to have.

I figured as much.


Nested ternaries like this:

   c = square ? a1  :  !hwc ? h*w  :  a3 > h*w ? h*w  :  a3;

are harder to decipher at first glance than 3 or 4 levels of indented 
if-then-elses.

But all the decision-making in one short line is a thing of beauty.





> I can explain the (positive) excitement only by some nerdy stance
> in this specific CLC domain.


Give the man his due.  It's extremely unique and excitement-worthy.

What's also very nice is there are no long lines that wrap.

Sure it's a bearded-lady novelty, but I think he knocked it out of the park.

[toc] | [prev] | [next] | [standalone]


Page 5 of 11 — ← Prev page 1 … 3 4 [5] 6 7 … 11  Next page →

Back to top | Article view | comp.lang.c


csiph-web