#Obfuscated C program collection

12 messages · Page 1 of 1 (latest)

median gale
#

This is more of a micro (maybe even nano) project as opposed to other projects in this forum, so I will try to make more of this type of programs and post them here.

Rudimentary Boolean Expression Evaluator

It's in the name. Supports only 3 operations: ! (not), & (and), | (or). Does not respect order of precedence or support parenthesis.
Compilation: gcc -ansi eval.c -o eval
Usage: ./eval 'expression'
Example: ```shell
$ ./eval '0 & !1'
0

```c
#include<stdio.h>
#define s switch
#define d default
#define q case
#define b break;
#define r return
#define i int
#define ch char

              i e,v,a,l;            main(             i  k,       ch*
             *m){if(k!=2         )r 1;ch*c         =m[1];for     (;*
            c;a      =0,       c++,    e++       ) {     for    (;;
           c++      )s(      * c)      {q      32:       b q   '!' 
          :a=!a;b  d:       goto      l;}     l:s       (*c   ){q
         '0':b q'1':a      =!a       ; b     q'&'      :v=   0;b
        q'|'      :v=     1;b       d:r     0;}       s(e   ){q
       0:k        =a;    b q       1:b     q 2       :if   (!v
      )k=       k&a      ;else   k=k       |a;     e=0    ;}}
     printf("%d",k       );}/*==**         :lo:.:re;     :m ipsum dol/
    or sit amet           ,cons             `ecte'      ur adipisic*/
median gale
#

Brainfuck Interpreter

Yet another brainfuck interpreter. I didn't feel like making any ASCII art for this, plus I have no idea what "art" I could make for such a program.
Programs are passed through command line argument and characters are read from stdin. Cells are chars. Tape pointer wraps on edges (if tape pointer is 0 and < is executed, tape pointer will be TAPE - 1). Has configurable EOF (NULL or no change).
Compilation: gcc -std=c89 bf.c -o bf -DTAPE=<tape size> -DEOFNULL=<number> (although there is one compound literal in the program, it still compiles???)
TAPE is the length of the tape. EOFNULL configures whether EOF is converted to 0 or left as is. If EOFNULL is 0, EOF will be left as is, otherwise EOF will be converted to 0.
Usage: ./bf 'brainfuck program'
Example (code taken from Wikipedia):

$ ./bf '>+++++++++[<++++++++>-]<.>+++++++[<++++>-]<+.+++++++..+++.>>>++++++++[<++++>-]<.>>>++++++++++[<+++++++++>-]<---.<<<<.+++.------.--------.>>+.>++++++++++.'
Hello World!
#include   <stdio.h>
#define c case/****/
#define q break;/**/
#define loop(s)/**/\
while(b){s else if(\
*a==91)b++;else if(\
*a==93)b--;}/******/
main(b,r,a,i,n)char*
a,**r,n[TAPE];{if (b
!=2)return 1;a=r[1];

i=0;n=(char[TAPE]){0
};while(*a){switch(*
a){c 62:i=++i%TAPE;q
c 60:i=--i%TAPE;q  c
43:n[i]++;q c 45:n[i
]--;q c 44:n[i]=get\
char();n[i]=EOFNULL?
(n[i]-EOF?n[i]:0):n[
i];q c 46:putchar(n[
i]);q c 91:if(n[i])q

b=1;loop(if(!*++a) {
puts("\nUnmatched [\
.");return 1;})q   c
93:if(!n[i])q b=-1 ;
loop(if(--a < r[1]){
puts("\nUnmatched [\
."); return 1;})   q
default:q } a++; } }
/*******************
*******************/
median gale
#

ASCII Mandelbrot set renderer

This one has somewhat actually readable code(hardly obfuscated), because the "image" generated by the program (I used the program to generate the layout for the code) had a little too many characters.
Compilation: gcc -std=c99 -lm mandelbrot.c -o mandelbrot
Usage: ./mandelbrot <x0> <y0> <x> <y> <step> <maximum iterations> <character set>
x0, y0 - coordinates of the origin relative to the top-left character (aka first row, first character);
x, y - size of the "frame" to draw the set in;
step - step between each coordinate(has type double)
maximum iterations - how many iterations the program should count before breaking (used to determine the "brightness" of a coordinate)
character set - what characters to use when rendering the set. Just try changing it to get how it works.

#

Example:

$ ./mandelbrot 20 14 31 29 0.1 200  ' .`^",:;Il!i><~+_-?][}{1)(|\\/tfjrxnuvczXYUJCLQ0OZmwqpdbkhao*#MW&8%B@$'
$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$
$$$$$$$$$$$$$$$$$$$$$$$$$$@@@@@@@@@@$$$$$$$$$$$$$$$$$$$$$$$$$$
$$$$$$$$$$$$$$$$$$@@@@@@@@@@@@@@@@@@@@@@@@@@$$$$$$$$$$$$$$$$$$
$$$$$$$$$$$$$$@@@@@@@@@@@@@@@@@@@@@@WW@@@@@@@@@@$$$$$$$$$$$$$$
$$$$$$$$$$$$@@@@@@@@@@@@@@@@@@@@@@@@BB%%  @@@@@@@@$$$$$$$$$$$$
$$$$$$$$@@@@@@@@@@@@@@@@@@@@@@@@@@BB%%##BB@@@@@@@@@@@@$$$$$$$$
$$$$$$@@@@@@@@@@@@@@@@@@@@@@@@@@BBBB    WWBB@@@@@@@@@@@@$$$$$$
$$$$$$@@@@@@@@@@@@@@@@@@@@@@BBBBBB%%    88%%BBBB@@@@@@@@$$$$$$
$$$$@@@@@@@@@@@@@@@@@@@@@@BB88  \\          88&&&&@@@@@@@@$$$$
$$$$@@@@@@@@@@@@@@@@@@@@BBBB88                  BB@@@@@@@@$$$$
$$@@@@@@@@@@@@BBBBBBBBBBBB88                    %%@@@@@@@@@@$$
$$@@@@@@@@@@@@BB&&88aa88%%##                    &&BB@@@@@@@@$$
$$@@@@@@@@@@BBBBWW      &&                      oo@@@@@@@@@@$$
$$@@@@BBBBBB88&&                                BB@@@@@@@@@@$$
$$                                            88BB@@@@@@@@@@$$
$$@@@@BBBBBB88&&                                BB@@@@@@@@@@$$
$$@@@@@@@@@@BBBBWW      &&                      oo@@@@@@@@@@$$
$$@@@@@@@@@@@@BB&&88aa88%%##                    &&BB@@@@@@@@$$
$$@@@@@@@@@@@@BBBBBBBBBBBB88                    %%@@@@@@@@@@$$
$$$$@@@@@@@@@@@@@@@@@@@@BBBB88                  BB@@@@@@@@$$$$
$$$$@@@@@@@@@@@@@@@@@@@@@@BB88  \\          88&&&&@@@@@@@@$$$$
$$$$$$@@@@@@@@@@@@@@@@@@@@@@BBBBBB%%    88%%BBBB@@@@@@@@$$$$$$
$$$$$$@@@@@@@@@@@@@@@@@@@@@@@@@@BBBB    WWBB@@@@@@@@@@@@$$$$$$
$$$$$$$$@@@@@@@@@@@@@@@@@@@@@@@@@@BB%%##BB@@@@@@@@@@@@$$$$$$$$
$$$$$$$$$$$$@@@@@@@@@@@@@@@@@@@@@@@@BB%%  @@@@@@@@$$$$$$$$$$$$
$$$$$$$$$$$$$$@@@@@@@@@@@@@@@@@@@@@@WW@@@@@@@@@@$$$$$$$$$$$$$$
$$$$$$$$$$$$$$$$$$@@@@@@@@@@@@@@@@@@@@@@@@@@$$$$$$$$$$$$$$$$$$
$$$$$$$$$$$$$$$$$$$$$$$$$$@@@@@@@@@@$$$$$$$$$$$$$$$$$$$$$$$$$$
$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$
#

Program:

median gale
#

Obfuscated C program collection

meager flame
#

that's some really cool code

median gale
#

thanks

tame minnow
median gale
#

Thanks, I already know about IOCCC

#

I hope to get close to the level of IOCCC submissions : - )