Skip to content

A try at writing obfuscated "pretty" C, with an easy problem

License

Notifications You must be signed in to change notification settings

chuahou/fizzbuzz

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

9 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

fizzbuzz

License: WTFPL

A try at writing some obfuscated "pretty" C, using the classic easy problem FizzBuzz

Programs

C89 pyramid

            i,t,f,j;
           p(char c){
          putchar(c);}
         g(){for(j=j^j;
        j++<2;0)p(122);}
       main(){char s[3]={
      37,100,21^21};while(
     i++<25<<2){if((t=i%3)*
    (f=i%5))printf(s,i);if(!
   t){p('\a'*10);p(0x69);g();
  }if(!f){p(0x42);p('2'*2+'"'/
 2);g();;}j=i<<5;while(--j!='('
>>2);p(j);}puts("Am I hired?");}

Modern hexagon

This works without exploiting C89, including stdio.h properly and using explicit types.

      #include<stdio.h>
     int i,t,f,j; void p
    (char c){putchar(c);}
   void g(){for(j=j^j;j++<
  2;0)p(122);}int main(void
 ){char s[3]={37,0x64,21^21}
;while(i++<25<<2){if((t=i%3)*
 (f=i%5))printf(s,i);if(!t){
  p('\a'*10);p(0x69);g();;}
   if(!f){p(0x42);p('2'*2+
    '"'/2);g();}j=i<<5;do
     ;while(--j!='('>>2)
      ;p(j);}return 0;}

It works on Hackerrank!

Building and running

The Makefile allows you to build using

make

upon which you can run using

./fizzbuzz

If you wish to install (why?) don't forget to set DESTDIR and PREFIX before running

make install

If you use Nix (yay), simply use the standard new commands like

nix build
nix run

About

A try at writing obfuscated "pretty" C, with an easy problem

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published