Movatterモバイル変換


[0]ホーム

URL:


Sorry, we no longer support your browser
Please upgrade toMicrosoft Edge,Google Chrome, orFirefox. Learn more about ourbrowser support.
Skip to main content

Stack Exchange Network

Stack Exchange network consists of 183 Q&A communities includingStack Overflow, the largest, most trusted online community for developers to learn, share their knowledge, and build their careers.

Visit Stack Exchange
Loading…
Code Golf

Return to Answer

added 11 characters in body
Abigail
  • 3.1k
  • 6
  • 18

Perl -M5.010/C (gcc -w), 112 bytes

//;say$_*2-1,Fizzbuzz for 1..500;<<'}';main(){for(int i=1;i<1001;i++){i%3?printf("%d",i):printf("FizzBuzz");}}

Try it online! (C)

Try it online! (Perl)

This hides the Perl code behind a C++ style comment, and the C code inside a Perl here doc, using the final character of the C code as the here doc terminator. The C++ style comment marker looks like an empty regular expression to Perl, which happily executes it, to no visible effect. Just as the here doc which is in void context.

The C version does not print any whitespace, the Perl version prints a newline after eachFizzBuzz.

Perl -M5.010/C (gcc -w), 112 bytes

//;say$_*2-1,Fizzbuzz for 1..500;<<'}';main(){for(int i=1;i<1001;i++){i%3?printf("%d",i):printf("FizzBuzz");}}

Try it online!

Try it online!

This hides the Perl code behind a C++ style comment, and the C code inside a Perl here doc, using the final character of the C code as the here doc terminator. The C++ style comment marker looks like an empty regular expression to Perl, which happily executes it, to no visible effect. Just as the here doc which is in void context.

The C version does not print any whitespace, the Perl version prints a newline after eachFizzBuzz.

Perl -M5.010/C (gcc -w), 112 bytes

//;say$_*2-1,Fizzbuzz for 1..500;<<'}';main(){for(int i=1;i<1001;i++){i%3?printf("%d",i):printf("FizzBuzz");}}

Try it online! (C)

Try it online! (Perl)

This hides the Perl code behind a C++ style comment, and the C code inside a Perl here doc, using the final character of the C code as the here doc terminator. The C++ style comment marker looks like an empty regular expression to Perl, which happily executes it, to no visible effect. Just as the here doc which is in void context.

The C version does not print any whitespace, the Perl version prints a newline after eachFizzBuzz.

deleted 174 characters in body
Abigail
  • 3.1k
  • 6
  • 18

Perl -M5.010/C (gcc -Wno-implicit-intw),130112 bytes

//;say$_*2-1,Fizzbuzz for 1..500;<<'}';#include<stdio.h>main(){for(int i=1;i<1001;i++){i%3?printf("%d",i):printf("FizzBuzz");}}

Try it online! (C)Try it online!

Try it online! (Perl)Try it online!

This hides the Perl code behind a C++ style comment, and the C code inside a Perl here doc, using the final character of the C code as the here doc terminator. The C++ style comment marker looks like an empty regular expression to Perl, which happily executes it, to no visible effect. Just as the here doc which is in void context.

The C version does not print any whitespace, the Perl version prints a newline after eachFizzBuzz.

The-Wno-implicit-int is only there to avoid TIO to emit warnings; compiling the code withgcc and no flags doesn't warn.

Perl -M5.010/C (gcc -Wno-implicit-int),130 bytes

//;say$_*2-1,Fizzbuzz for 1..500;<<'}';#include<stdio.h>main(){for(int i=1;i<1001;i++){i%3?printf("%d",i):printf("FizzBuzz");}}

Try it online! (C)

Try it online! (Perl)

This hides the Perl code behind a C++ style comment, and the C code inside a Perl here doc, using the final character of the C code as the here doc terminator. The C++ style comment marker looks like an empty regular expression to Perl, which happily executes it, to no visible effect. Just as the here doc which is in void context.

The C version does not print any whitespace, the Perl version prints a newline after eachFizzBuzz.

The-Wno-implicit-int is only there to avoid TIO to emit warnings; compiling the code withgcc and no flags doesn't warn.

Perl -M5.010/C (gcc -w),112 bytes

//;say$_*2-1,Fizzbuzz for 1..500;<<'}';main(){for(int i=1;i<1001;i++){i%3?printf("%d",i):printf("FizzBuzz");}}

Try it online!

Try it online!

This hides the Perl code behind a C++ style comment, and the C code inside a Perl here doc, using the final character of the C code as the here doc terminator. The C++ style comment marker looks like an empty regular expression to Perl, which happily executes it, to no visible effect. Just as the here doc which is in void context.

The C version does not print any whitespace, the Perl version prints a newline after eachFizzBuzz.

Abigail
  • 3.1k
  • 6
  • 18

Perl -M5.010/C (gcc -Wno-implicit-int), 130 bytes

//;say$_*2-1,Fizzbuzz for 1..500;<<'}';#include<stdio.h>main(){for(int i=1;i<1001;i++){i%3?printf("%d",i):printf("FizzBuzz");}}

Try it online! (C)

Try it online! (Perl)

This hides the Perl code behind a C++ style comment, and the C code inside a Perl here doc, using the final character of the C code as the here doc terminator. The C++ style comment marker looks like an empty regular expression to Perl, which happily executes it, to no visible effect. Just as the here doc which is in void context.

The C version does not print any whitespace, the Perl version prints a newline after eachFizzBuzz.

The-Wno-implicit-int is only there to avoid TIO to emit warnings; compiling the code withgcc and no flags doesn't warn.


[8]ページ先頭

©2009-2025 Movatter.jp