CodeFuck
Jump to navigation
Jump to search
CodeFuck is a variant of BrainFuck.
It avoids repetitions and adds new operators
Hello World
CodeFuck
+10[>+7>+10>+3>+<4-]>+2.>+.+7.2+3.>+2.<2+15.>.+3.-6.-8.>+.>.
BrainFuck
++++++++++[>+++++++>++++++++++>+++>+<<<<-]>++.>+.+++++++..+++.>++.<<+++++++++++++++.>.+++.------.--------.>+.>.
Operators
Opertator | Description |
---|---|
> | Inc Cell |
< | Dec Cell |
+ | Inc Octet |
- | Dec Octet |
. | Output ASCII |
; | Output Integer |
, | Input ASCII |
: | Input Integer |
f | create function |
F | run function |
[ | While != 0 |
/ | While == 0 |
( | If == 0 |
{ | If != 0 |
! | If > 0 |
? | If < 0 |
| with ( { ! ? ex : |? |
Else If ... |
& | Else |
] \ ) } # | Close condition block |
_ | Load VAR |
$ | VAR value |
%your comment% | Comment |
Conditions examples
Example 1
CodeFuck
(.|!.|?.)
C
if (*cell==0) { putchar(*cell); } else if (*cell>0) { putchar(*cell); } else if (*cell<0) { putchar(*cell); }
Example 2
CodeFuck
{100.|?50.&.}
C
if (*cell!=100) { putchar(*cell); } else if (*cell<50) { putchar(*cell); } else { putchar(*cell); }
Example 3
CodeFuck
[100{80.|!30.|?30.&.}+]
C
while (*cell!=100) { if (*cell!=80) { putchar(*cell); } else if (*cell>30) { putchar(*cell); } else if (*cell<30) { putchar(*cell); } else { putchar(*cell); } ++*cell; }
Functions examples
The creation of a function always takes place before any other operations
CodeFuck
f1 +65. f . F1
or
f1+65.f.F1
C
long f1(long cell) { [...] *cell+=65; putchar(*cell); return cell*; } int main(int argc, char **argv) { [...] putchar(*cell); *cell=f1(*cell); [...] }
Example hello.cf
Code
+10[ >+7 >+10 >+3 >+ <4- ] >+2. >+. +7.2 +3. >+2. <2+15. >. +3. -6. -8. >+. >. "Salut le monde " >5 +48;" == "." " [-] +65;" == "." " [-] +97;" == "." " [-];" " /+5\;" " {-5};" " (+);" "-;" *cell ";" == ";" " [15+] (15"*cell ";" == ";" ") /15-\ {15"*cell ";" != 15"_}" *cell ";" == "($;)[-]_" "
Output
Hello World! Salut le monde! 48 == 0 65 == A 97 == a 05010 *cell 0 == 0 *cell 15 == 15 *cell 14 not 15 14 == 14
Example Math.cf
Code
>5+43 >+45 <6 "Add ":>"+"< :[<+>-]"= "<; >[-]<[-] " Sub ":>"-"< :[<->-]"= "<; >[-]<[-] " Mul ":_"x" >:[>+$<-]"= ">; <[-]>[-]
Output
Add 10 + 10 = 20 Sub 78 - 45 = 33 Mul 3 x 6 = 18
Advanced Example
Code
"CodeFuck Math Options : 0 Addition 1 Soustraction 2 Multiplication 3 Division : ":" " ( % CHAR + % >5+43<5 "Addition " :>5.<4" ":[<+>-]"= "<;" " |(1 % CHAR - % >6+45<6 - "Soustraction " :>6.<5" ":[<->-]"= "<;" " |(2 -2 "Multiplication " :_"x ">:[>+$<-]"= ">;" " |(3 -3 "Division " :>"÷ ":> <2[ >[->+>+<2] >[-<2- [>]>3 [ <[ >3-<3[-] ]>2 ]<2 ]>3+ <2[ -<2+>2 ]<3 ] >[-]>4[-<5+>5] <4+6<"= ";" " )
Output
CodeFuck Math Options 0 Addition 1 Soustraction 2 Multiplication 3 Division n° 1 Soustraction 5675 - 55 = 5620
C Generate
#include <stdio.h> #include <stdlib.h> void memsetcf(char *array, int z, long unsigned int s ); int main(int argc, char **argv); void memsetcf(char *array, int z, long unsigned int s ) { long unsigned int p; for (p=z; p<=s; p++){ array[p]=z; } } int main(int argc, char **argv) { long *cell = calloc(30000, 1); long *cells = cell; char num[8]; char c; int i=0; int var=0; if (!cell) { fprintf(stderr, "Error allocating memory.\n"); return 1; } /*--------------------------------------------*/ /*------------------CodeFuck------------------*/ /*--------------------------------------------*/ putchar(67); putchar(111); putchar(100); putchar(101); putchar(70); putchar(117); putchar(99); putchar(107); putchar(32); putchar(77); putchar(97); putchar(116); putchar(104); putchar(10); putchar(10); putchar(79); putchar(112); putchar(116); putchar(105); putchar(111); putchar(110); putchar(115); putchar(32); putchar(58); putchar(10); putchar(32); putchar(32); putchar(32); putchar(32); putchar(32); putchar(32); putchar(32); putchar(32); putchar(48); putchar(32); putchar(32); putchar(32); putchar(65); putchar(100); putchar(100); putchar(105); putchar(116); putchar(105); putchar(111); putchar(110); putchar(10); putchar(32); putchar(32); putchar(32); putchar(32); putchar(32); putchar(32); putchar(32); putchar(32); putchar(49); putchar(32); putchar(32); putchar(32); putchar(83); putchar(111); putchar(117); putchar(115); putchar(116); putchar(114); putchar(97); putchar(99); putchar(116); putchar(105); putchar(111); putchar(110); putchar(10); putchar(32); putchar(32); putchar(32); putchar(32); putchar(32); putchar(32); putchar(32); putchar(32); putchar(50); putchar(32); putchar(32); putchar(32); putchar(77); putchar(117); putchar(108); putchar(116); putchar(105); putchar(112); putchar(108); putchar(105); putchar(99); putchar(97); putchar(116); putchar(105); putchar(111); putchar(110); putchar(10); putchar(32); putchar(32); putchar(32); putchar(32); putchar(32); putchar(32); putchar(32); putchar(32); putchar(51); putchar(32); putchar(32); putchar(32); putchar(68); putchar(105); putchar(118); putchar(105); putchar(115); putchar(105); putchar(111); putchar(110); putchar(10); putchar(32); putchar(32); putchar(32); putchar(32); putchar(32); putchar(32); putchar(58); putchar(32); *cell = getchar(); while (*cell!=0) { num[i]=*cell; i++; *cell-=10; if (*cell!=0) { *cell+=10; *cell = getchar(); } } *cell = atoi(num); memsetcf(num, 0, sizeof (num)); i=0; putchar(10); if (*cell==0) { /* CHAR + */ cell+=5; *cell+=43; cell-=5; putchar(65); putchar(100); putchar(100); putchar(105); putchar(116); putchar(105); putchar(111); putchar(110); putchar(10); putchar(32); putchar(32); *cell = getchar(); while (*cell!=0) { num[i]=*cell; i++; *cell-=10; if (*cell!=0) { *cell+=10; *cell = getchar(); } } *cell = atoi(num); memsetcf(num, 0, sizeof (num)); i=0; cell+=5; putchar(*cell); cell-=4; putchar(32); *cell = getchar(); while (*cell!=0) { num[i]=*cell; i++; *cell-=10; if (*cell!=0) { *cell+=10; *cell = getchar(); } } *cell = atoi(num); memsetcf(num, 0, sizeof (num)); i=0; while (*cell!=0) { --cell; ++*cell; ++cell; --*cell; } putchar(61); putchar(32); --cell; printf("%li", *cell); putchar(32); putchar(32); putchar(32); putchar(32); putchar(32); putchar(32); putchar(32); putchar(32); putchar(10); } else if (*cell==1) { /* CHAR - */ cell+=6; *cell+=45; cell-=6; --*cell; putchar(83); putchar(111); putchar(117); putchar(115); putchar(116); putchar(114); putchar(97); putchar(99); putchar(116); putchar(105); putchar(111); putchar(110); putchar(10); putchar(32); putchar(32); *cell = getchar(); while (*cell!=0) { num[i]=*cell; i++; *cell-=10; if (*cell!=0) { *cell+=10; *cell = getchar(); } } *cell = atoi(num); memsetcf(num, 0, sizeof (num)); i=0; cell+=6; putchar(*cell); cell-=5; putchar(32); *cell = getchar(); while (*cell!=0) { num[i]=*cell; i++; *cell-=10; if (*cell!=0) { *cell+=10; *cell = getchar(); } } *cell = atoi(num); memsetcf(num, 0, sizeof (num)); i=0; while (*cell!=0) { --cell; --*cell; ++cell; --*cell; } putchar(61); putchar(32); --cell; printf("%li", *cell); putchar(10); } else if (*cell==2) { *cell-=2; putchar(77); putchar(117); putchar(108); putchar(116); putchar(105); putchar(112); putchar(108); putchar(105); putchar(99); putchar(97); putchar(116); putchar(105); putchar(111); putchar(110); putchar(10); putchar(32); putchar(32); *cell = getchar(); while (*cell!=0) { num[i]=*cell; i++; *cell-=10; if (*cell!=0) { *cell+=10; *cell = getchar(); } } *cell = atoi(num); memsetcf(num, 0, sizeof (num)); i=0; var=*cell; putchar(120); putchar(32); ++cell; *cell = getchar(); while (*cell!=0) { num[i]=*cell; i++; *cell-=10; if (*cell!=0) { *cell+=10; *cell = getchar(); } } *cell = atoi(num); memsetcf(num, 0, sizeof (num)); i=0; while (*cell!=0) { ++cell; *cell+=var; --cell; --*cell; } putchar(61); putchar(32); ++cell; printf("%li", *cell); putchar(10); } else if (*cell==3) { *cell-=3; putchar(68); putchar(105); putchar(118); putchar(105); putchar(115); putchar(105); putchar(111); putchar(110); putchar(10); putchar(32); putchar(32); *cell = getchar(); while (*cell!=0) { num[i]=*cell; i++; *cell-=10; if (*cell!=0) { *cell+=10; *cell = getchar(); } } *cell = atoi(num); memsetcf(num, 0, sizeof (num)); i=0; ++cell; putchar(195); putchar(183); putchar(32); *cell = getchar(); while (*cell!=0) { num[i]=*cell; i++; *cell-=10; if (*cell!=0) { *cell+=10; *cell = getchar(); } } *cell = atoi(num); memsetcf(num, 0, sizeof (num)); i=0; ++cell; cell-=2; while (*cell!=0) { ++cell; while (*cell!=0) { --*cell; ++cell; ++*cell; ++cell; ++*cell; cell-=2; } ++cell; while (*cell!=0) { --*cell; cell-=2; --*cell; while (*cell!=0) { ++cell; } cell+=3; while (*cell!=0) { --cell; while (*cell!=0) { cell+=3; --*cell; cell-=3; while (*cell!=0) { --*cell; } } cell+=2; } cell-=2; } cell+=3; ++*cell; cell-=2; while (*cell!=0) { --*cell; cell-=2; ++*cell; cell+=2; } cell-=3; } ++cell; while (*cell!=0) { --*cell; } cell+=4; while (*cell!=0) { --*cell; cell-=5; ++*cell; cell+=5; } cell-=4; *cell+=6; --cell; putchar(61); putchar(32); printf("%li", *cell); putchar(10); } /*--------------------------------------------*/ /*----------------End CodeFuck----------------*/ /*--------------------------------------------*/ free(cells); return 0; }