Groups | Search | Server Info | Login | Register
Groups > comp.os.linux.misc > #77469
| From | Pancho <Pancho.Jones@protonmail.com> |
|---|---|
| Newsgroups | comp.os.linux.misc |
| Subject | Re: Simple Programming Challenge |
| Date | 2025-11-13 10:45 +0000 |
| Organization | A noiseless patient Spider |
| Message-ID | <10f4cs5$23245$1@dont-email.me> (permalink) |
| References | (2 earlier) <project-20251112171620@ram.dialup.fu-berlin.de> <18774fee1aa33cb0$22907$3467166$802601b3@news.usenetexpress.com> <10f2g5o$1jjgu$1@dont-email.me> <10f2gd4$1jjgu$2@dont-email.me> <wwvecq2vm1n.fsf@LkoBDZeT.terraraq.uk> |
On 11/13/25 00:00, Richard Kettlewell wrote:
> Pancho <Pancho.Jones@protonmail.com> writes:
>> On 11/12/25 17:29, Pancho wrote:
>>> On 11/12/25 16:41, Joe Fantastic wrote:
>>>> Too many additions.
>>>>
>>> #include <stdio.h>
>>> #include <stdlib.h>
>>> int main()
>>> {
>>> int i=1;
>>> while (i < 990)
>>> {
>>> printf( "%d\n", i++);
>>> printf( "%d\n", i++);
>>> printf( "%s\n", "Fizz"); i++;
>>> printf( "%d\n", i++);
>>> printf( "%s\n", "Buzz"); i++;
>>> printf( "%s\n", "Fizz"); i++;
>>> printf( "%d\n", i++);
>>> printf( "%d\n", i++);
>>> printf( "%s\n", "Fizz"); i++;
>>> printf( "%s\n", "Buzz"); i++;
>>> printf( "%d\n", i++);
>>> printf( "%d\n", i++);
>>> printf( "%s\n", "Fizz"); i++;
>>> printf( "%d\n", i++);
>>> printf( "%s\n", "FizzBuzz"); i++;
>>> }
>>> printf( "%d\n", i++);
>>> printf( "%d\n", i++);
>>> printf( "%s\n", "Fizz"); i++;
>>> printf( "%d\n", i++);
>>> printf( "%s\n", "Buzz"); i++;
>>> printf( "%s\n", "Fizz"); i++;
>>> printf( "%d\n", i++);
>>> printf( "%d\n", i++);
>>> printf( "%s\n", "Fizz"); i++;
>>> printf( "%s\n", "Buzz"); i++;
>>> }
>
> l-)
>
>> whoops 12 and 13 the wrong way around. No task is too small, for me to
>> fuck up :o).
>
> #include <stdio.h>
>
> int main(void) {
> static const char *f[] = {
> "fizzbuzz\n",
> "buzz\n",
> "fizz\n",
> "%d\n",
> };
> unsigned r = 2;
> for(int i = 1; i <= 1000; i++) {
> printf(f[!(r & 4681) + (!(r & 1057) << 1)], i);
> r <<= 1;
> r |= r >> 15;
> }
> return 0;
> }
>
> If you hate additions then ‘+’ in the middle could be ‘|’, but x86-64
> GCC doesn’t spot the optimization to lea if you do tha
>
lol! If I hadn't been thinking "wheels" like in the Sieve of
Eratosthenes, I would never have understood that code.
Back to comp.os.linux.misc | Previous | Next — Previous in thread | Next in thread | Find similar
Simple Programming Challenge Joe Fantastic <jf@linux.rocks> - 2025-11-12 15:19 +0000
Re: Simple Programming Challenge "Joel W. Crump" <joelcrump@gmail.com> - 2025-11-12 10:31 -0500
Re: Simple Programming Challenge John Ames <commodorejohn@gmail.com> - 2025-11-12 08:07 -0800
Re: Simple Programming Challenge ram@zedat.fu-berlin.de (Stefan Ram) - 2025-11-12 16:18 +0000
Re: Simple Programming Challenge Joe Fantastic <jf@linux.rocks> - 2025-11-12 16:41 +0000
Re: Simple Programming Challenge Pancho <Pancho.Jones@protonmail.com> - 2025-11-12 17:29 +0000
Re: Simple Programming Challenge Pancho <Pancho.Jones@protonmail.com> - 2025-11-12 17:33 +0000
Re: Simple Programming Challenge Richard Kettlewell <invalid@invalid.invalid> - 2025-11-13 00:00 +0000
Re: Simple Programming Challenge Pancho <Pancho.Jones@protonmail.com> - 2025-11-13 10:45 +0000
Re: Simple Programming Challenge Lawrence D’Oliveiro <ldo@nz.invalid> - 2025-11-12 23:30 +0000
Re: Simple Programming Challenge ram@zedat.fu-berlin.de (Stefan Ram) - 2025-11-13 13:24 +0000
Re: Simple Programming Challenge Ralf Fassel <ralfixx@gmx.de> - 2025-11-13 16:16 +0100
Re: Simple Programming Challenge Fritz Wuehler <fritz@spamexpire-202511.rodent.frell.theremailer.net> - 2025-11-12 18:37 +0100
Re: Simple Programming Challenge Brock McNuggets <brock.mcnuggets@gmail.com> - 2025-11-12 20:05 +0000
Re: Simple Programming Challenge "Joel W. Crump" <joelcrump@gmail.com> - 2025-11-12 15:30 -0500
Re: Simple Programming Challenge Brock McNuggets <brock.mcnuggets@gmail.com> - 2025-11-12 20:50 +0000
Re: Simple Programming Challenge John McCue <jmclnx@gmail.com.invalid> - 2025-11-12 17:22 +0000
Re: Simple Programming Challenge c186282 <c186282@nnada.net> - 2025-11-12 23:57 -0500
Re: Simple Programming Challenge Lawrence D’Oliveiro <ldo@nz.invalid> - 2025-11-12 23:24 +0000
csiph-web