Skip to content

Instantly share code, notes, and snippets.

@clippit
Created March 19, 2012 16:32
Show Gist options
  • Save clippit/2118324 to your computer and use it in GitHub Desktop.
Save clippit/2118324 to your computer and use it in GitHub Desktop.
Play a 24 Game with four 0s
#include <stdio.h>
int main() {
printf("%d\n", '0'/(('0'+'0')/'0'));
printf("%d\n", '0'>>'0'/'0'+0);
printf("%d\n", -~-~-~-~-~-~0-~-~-~-~-~-~0-~-~-~-~-~-~0-~-~-~-~-~-~0);
return 0;
}
@deltamaster
Copy link

I love the third solution!
0's can be put after any '~' I like.

@deltamaster
Copy link

printf("%d\n", ((-0<<-0)+-0)<<---0);
printf("%d\n", ((!0<<!0)+!0)<<-
-
-~0);

@CanoeFZH
Copy link

((0 – (~0)) << (0 – (~0))) << ((0 – (~0)) << (0 – (~0))) << (0 – (~0)) | ((0 – (~0)) << (0 – (~0))) << ((0 – (~0)) << (0 – (~0)))
(((0 - (~0)) << (0 - (~0))) | (0 - (~0))) << (((0 - (~0)) << (0 - (~0))) | (0 - (~0)))
'0' >> (0 - (~0))

@deltamaster
Copy link

Oops, only 4 zeros available...

@CanoeFZH
Copy link

O_0... I have just forgot that rule..

@zengqu
Copy link

zengqu commented Mar 23, 2012

printf("%d\n",('0'-0)/(printf("%c",0) + printf("%c",0)));

@topin27
Copy link

topin27 commented Mar 26, 2012

3 zeros is enough~

@zhangjiantao
Copy link

2 zeros is enough~~
'0'>>!0

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment