Beefy Boxes and Bandwidth Generously Provided by pair Networks
The stupid question is the question not asked
 
PerlMonks  

Re: Re: (Golf) Mandelbrot Fractal

by educated_foo (Vicar)
on May 08, 2002 at 21:48 UTC ( [id://165194]=note: print w/replies, xml ) Need Help??


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.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://165194]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others learning in the Monastery: (4)
As of 2024-04-26 00:23 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found