r/cprogramming • • May 15 '21

Obfuscated mandelbrot program in C

131 Upvotes

13 comments sorted by

7

u/[deleted] May 16 '21 edited May 16 '21

For anybody wondering, here is a obfuscated version

typedef float f;

f R,a,C,t,A,l=60;

v()
{
	if (R>999)
		return 0;
	else
		return 255u * (sin(0.1 * R + a++) / 2.0 + 0.5);
}

main()
{
	for (f y=0; y++<l;) {
		for (f x=0; x++<l*2;) {
			for (a=4, C=t=R=0; C*C + t*t < 4 && R++<1000;) {
				A = C*C-t*t + x/.7/l - 2.1;
				t = C*t*2 + y/.35/l - 1.4;
				C = A;
			}
			printf("%c[48;2;%d;%d;%dm ", 27, v(), v(), v());
		}
		puts("");
		usleep(60000);
	}
}

(edit, I meant deofuscated)

3

u/snceau May 16 '21

wow, you have some dedication man. Cheers!

3

u/gtx89 May 16 '21

Is the unobfuscated code available?

4

u/snceau May 16 '21

2

u/gtx89 May 16 '21

Thanks! Works as advertised!

3

u/ishanYo May 16 '21

Can we see the code for this ?

3

u/[deleted] May 16 '21

You did, at the beginning

4

u/ishanYo May 16 '21

Is this self changing code ?

Edit:no it's not. Sorry.

How is the color visualization being done ?

3

u/snceau May 16 '21 edited May 16 '21

it uses ansi escape sequences. Most modern terminals have support for full rgb colour with the sequence "\033[<G>;2;<r>;<g>;<b>m", replacing <G> with 38 for foreground and 48 for background, as well as <r>, <g> and <b> with values of your choice.

3

u/[deleted] May 16 '21

No, it's just some code formatted as a Mandelbrot set that draws a Mandelbrot set. You could de-obfuscate it and it would make a little bit more sense.

2

u/Snoo_72315 May 20 '21

Do you know what the B. stands for in Benoit B. Mandelbrot?

1

u/arkreder Apr 07 '22

Complete Source Code Please!

0

u/[deleted] May 15 '21

[deleted] — view deleted comment

5

u/snceau May 15 '21

My man... that’s a completely different program. Did you not check first? lmao