in reply to Re: (Golf) Mandelbrot Fractal
in thread (Golf) Mandelbrot Fractal

125:
-l map{$i=$_/20-1;print map{$r=$;=$_/20-2.3;$z=$i;$n=$z*$z,$m=$r*$r,$z +=2*$r*$z+$i,$r=$m-$n+$;for a..z;$m<4?$":"+"}0..59}0..39
/s
Update: 123
-l map{$i=$_/20,print map{$r=$;=$_/20;$z=$i;$n=$z*$z,$m=$r*$r,$z=2*$r* +$z+$i,$r=$m-$n+$;for a..z;$m<4?$":"+"}-46..13}-20..19

Replies are listed 'Best First'.
Re: Re: Re: (Golf) Mandelbrot Fractal
by belg4mit (Prior) on May 08, 2002 at 23:27 UTC
    With some bending of the rules(?), we get a little more detail, and 117 chars

    perl -Mconstant=Z,20 -l map{$i=$_/Z,print map{$r=$;=$_/Z;$z=$i;$n=$z*$z,$m=$r*$r,$z=2*$r*$z+$i +,$r=$m-$n+$;for a..z;$m<4?$":"+"}-46..Z}-19..Z

    116 @ Wed May 8 19:50:10 EDT 2002

    map{$i=$_/Z,print map{$r=$;=$_/Z;$z=$i;$n=$z*$z,$z=2*$r*$z+$i,$r=($m=$ +r*$r)-$n+$;for a..z;$m<4?$":"+"}-46..Z}-19..Z

    BTW, I like the use of $; :-)

    UPDATE: Changed outside range from -20..Z to -19..Z to eliminate extra lines of +.

    --
    perl -pew "s/\b;([mnst])/'$1/g"

      Jesus christ ...

      But I think using the constant declaration on the outside is cheating. Hmm!


      --
      Ash OS durbatulk, ash OS gimbatul,
      Ash OS thrakatulk, agh burzum-ishi krimpatul!
      Uzg-Microsoft-ishi amal fauthut burguuli.

        Not cheating, but you have to count it as part of the solution, which puts it back at 134-ish.
Re^3: (Golf) Mandelbrot Fractal
by tadman (Prior) on May 09, 2002 at 00:51 UTC
    That use of $; is very clever, as it parses correctly and allows you to omit the brackets for the for. Combining this with other modifications yields 122 chars of obfuscated goodness:
    print map{$i=$_/20;$/,map{$r=$;=$_/20;$z=$i;$n=$z*$z,$z=2*$r*$z+$i,$r=($m=$r*$r)-$n+$;for a..z;$m<4?$":"+"}-46..13}-20..19
    Further savings if you choose 'X' instead of '+':
    print map{$i=$_/20;$/,map{$r=$;=$_/20;$z=$i;$n=$z*$z,$z=2*$r*$z+$i,$r=($m=$r*$r)-$n+$;for a..z;$m<4?$":X}-46..13}-20..19
    Here is the original C code, just for comparison, at 182 characters:
    void main(){double O,x,o,I,l,i;char _;for(l=-1;l<1;l+=.05,putc ;i<.7;i+=.05,putchar(_?'?':':'),O=i,x=l,o=I=(_=1)--)for(;++_&& );x=2*O*x+l,O=o-I+i);}
    C allows for shorter variable names, and Perl still comes out ahead. Crazy.
      The only catch appears to be that, when I actually run this, it doesn't work. Of course, I could well be going mad.