Groups | Search | Server Info | Keyboard shortcuts | Login | Register
Groups > comp.os.linux.misc > #77409
| From | ram@zedat.fu-berlin.de (Stefan Ram) |
|---|---|
| Newsgroups | comp.os.linux.misc |
| Subject | Re: Simple Programming Challenge |
| Date | 2025-11-12 16:18 +0000 |
| Organization | Stefan Ram |
| Message-ID | <project-20251112171620@ram.dialup.fu-berlin.de> (permalink) |
| References | <18774b74533f13ac$14097$3668313$802601b3@news.usenetexpress.com> <5L1RQ.59910$3VN7.27458@fx41.iad> |
"Joel W. Crump" <joelcrump@gmail.com> wrote or quoted:
>Why would anyone waste their time on such a lame project?
I don't know.
fizzbuzz.cpp
#include <iostream>
#include <string>
int main() {
const int max = 1000;
std::string out;
out.reserve(10000);
int c3 = 0, c5 = 0;
for (int i = 1; i <= max; ++i) {
c3++; c5++;
if (c3 == 3 && c5 == 5) {
out += "FizzBuzz\n";
c3 = 0; c5 = 0;
} else if (c3 == 3) {
out += "Fizz\n";
c3 = 0;
} else if (c5 == 5) {
out += "Buzz\n";
c5 = 0;
} else {
out += std::to_string(i);
out += '\n';
}
}
std::cout << out;
return 0;
}
g++ -Ofast -march=native -flto -fprefetch-loop-arrays \
-funroll-loops -fno-exceptions -fno-rtti fizzbuzz.cpp -o fizzbuzz
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