$}=1|1<<pop;print($"x$},(map$_?$=:$"x2,@;),
$/),@;=(1,map$;[$_]^$;[-$_],1..@;)while$}--
This little program draws the sierpinski triangle fractal. Specify the size on the command line (should be about 5 depending on your screen size)
--MrNobo1024 s]]HrLfbfe|EbBibmv]e|s}w}ciZx^RYhL}e^print
Re: Sierpinski Triangle by Len (Friar) on Aug 08, 2002 at 08:15 UTC |
MrNobo1024++ for this math magic !
If you feel inspired by this kind of geometric stuff,
check out The Geometry Junkyard for a huge collection of geometrical and recreational math. | [reply] |
Re: Sierpinski Triangle by Rudif (Hermit) on Aug 10, 2002 at 21:37 UTC |
Neat.
And here is a default-supplying line, to prepend to it.
@ARGV||push@ARGV,5;
Rudif | [reply] [d/l] |
Re: Sierpinski Triangle by hossman (Parson) on Aug 12, 2002 at 06:39 UTC |
Very cool... but i made two tweaks, one is a
simplified version of Rudif's default suggestion,
and the other
changes the text to something more triangle-ish (i don't
think it significantly reduces the obfuscation)
$}=1|1<<(pop||3);print($"x$},(map$_?'/\\':$"x2,
@;),$/),@;=(1,map$;[$_]^$;[-$_],1..@;)while$}--
| [reply] [d/l] |
Re: Sierpinski Triangle by eyepopslikeamosquito (Canon) on Aug 17, 2002 at 06:38 UTC |
#!/usr/bin/perl
/\
/=~(
'(?{'.
('`'|'%'
).('['^'-'
).('`'|'!').
('`'|',').'"'.
'\\$-=!\\$%|!\\'
.'$%<<('.('['^'+')
.('`'|'/').('['^'+')
.'||'.('^'^('`'|'*')).
');'.('['^'+').('['^')')
.('`'|')').('`'|'.').('['^
'/').'(\\$\\"'.('['^'#').''.
'\\$-,('.('`'|'-').('`'|'!').(
'['^'+').'\\$_?'."'".'/\\\\\\\\'
."'".':\\$\\".\\$\\",\\@;),\\$/),'
.'\\@;=(!\\$%,'.('`'|'-').('`'|'!').
('['^'+').'\\$;[\\$_]^\\$;[-\\$_],!\\'
.'$%..\\@;)'.('['^',').('`'|'(').(('`')|
')').('`'|',').('`'|'%').'\\$---"})');'\+'
| [reply] [d/l] |
Re: Sierpinski Triangle by eyepopslikeamosquito (Canon) on Aug 17, 2002 at 16:16 UTC |
Here is an alternative solution.
This one is a little shorter and strict and warning safe.
Also it does not emit an empty first line.
I developed it from ideas in previous solutions posted to fwp@perl.org.
See golf thread.
If the alien golfers take up my challenge, it will be significantly shortened.
$_=$"x((1|1<<(pop||4))-1)."/\\
";print,s,(?<=\\)..,$&^"\017|",ge,s,$,/\\,while+s+^ ++
| [reply] [d/l] |
|
#!perl -l
$_=$"x2**(pop||4);s'$'/\\',print,s/(?<=\\)../$&^aD^n8/egwhile+s\^ \\
Here are some other solutions (without default argument)
they concocted during their fidgeting:
$_=$"x(1<<pop);print,s/(?<=\\)../$&^"\17|"/egwhile+s^\n?$^/\\\n^,s\^ \
+\
$_=$"x(1<<pop).$/;print,s/(?<=\\)../$&^"\17|"/egwhile+s^$^/\\^,s\^ \\
-lX $_=$"x2**pop;print,s/(?<=\\)../$&^"\17|"/egwhile+s*$*/\\**s+^ ++
-lX $_=$"x2**pop;print,s/(?<=\\)../$&^"\17|"/egwhile+s-^ (.*)-$+/\\-
-l $_=$"x2**pop;s'$'/\\',print,s/(?<=\\)../$&^"\17|"/egwhile+s\^ \\
-l $_=$"x2**pop;s'$'/\\',print,s/(?<=\\)../$&^aD^n8/egwhile+s\^ \\
| [reply] [d/l] [select] |
Re: Sierpinski Triangle by eyepopslikeamosquito (Canon) on Aug 21, 2002 at 12:36 UTC |
Still going!
Though not shortest, I find this one amusing for some reason.
Oh, and I have given it a name: "five substitutions".
#!perl -l
s--$"x$^F**pop-e,s-.-s,,,,s,$,/\\,,print,s,(?<=/.)..,$&^h9^gE,ge-ge
| [reply] [d/l] |
|
|