in reply to Playing Golf on Saturn
D'oh, don't need to calculate the maximum line length (in $-) since it's known to be 82 for shape Saturn. That, plus some routine whittling has reduced the golf score by 39 strokes down to 452.
sub I{s-^-$"x$_[1]-gem;$/x$_[0].$_.$/} sub D{$~=shift;system($^O=~Win?CLS:"clear"),print, select$Z,$Z,$Z,$~for@_} sub R{$i=0;join$/,map{$j=0;join"",grep!($j++%$_[0]),/./g} grep!($i++%$_[0]),@:} $S=join"",@:=<DATA>;chop@:; $_.=$"x-(y---c-82)for@:; D.3,@X=(I(20,41,$_="."),I(20,41,$_=O),I(15,31,$_=R 4), I(13,28,$_=R 3),I(10,20,$_=R 2),$S); D.2,(map{$n=$_;join($/,map$_ x$n,R($_)=~/.+/g,"")x$_}2..4) [0..2,1,0]; D.1,$S,join"",map+reverse.$/,@:for$%..5;D.3,reverse@X
Update: Down to 437 now. There must be more there, let's see if thospel or mtve can beat this by 100 strokes. :-)
sub I{$x=pop;$x=~s-^-$"x$_[1]-gem;$/x$_[0].$x.$/} sub D{$~=shift;system($^O=~Win?CLS:"clear"),print, select$Z,$Z,$Z,$~for@_} sub R{$i=0;join$/,map{$j=0;join"",grep!($j++%$_[0]),/./g} grep!($i++%$_[0]),@:} $S=join"",@:=<DATA>; chop,$_.=$"x-(y---c-82)for@:; D.3,@X=(map(I(20,41,$_),".",O),I(15,31,R 4), I(13,28,R 3),I(10,20,R 2),$S); D.2,map{$n=$_;join($/,map$_ x$n,R($_)=~/.+/g,"")x$_}2..4,3,2; D.1,$S,join"",map+reverse.$/,@:for$%..5;D.3,reverse@X
Still chipping away... 425
sub I{$x=pop;$x=~s-^-$"x$_[1]-gem;$/x$_[0].$x.$/} sub D{system$^O=~Win?CLS:"clear";print;select$Z,$Z,$Z,pop} sub R{$i=0;join$/,map{$j=0;join"",grep!($j++%$_[0]),/./g} grep!($i++%$_[0]),@:} $S=join"",@:=<DATA>; chop,$_.=$"x-(y---c-82)for@:; D.3for@X=(map(I(20,41,$_),".",O),I(15,31,R 4), I(13,28,R 3),I(10,20,R 2),$S); for$n(2..4,3,2){$_=join($/,map$_ x$n,R($n)=~/.+/g,"")x$n;D.2} D.1for($S,join"",map+reverse.$/,@:)x6; D.3for+reverse@X
|
|---|