 Front page | perl.golf | Postings from July 2002

## Re: more minigolf

From:
Jasper McCrea
Date:
July 10, 2002 07:26
Subject:
Re: more minigolf
Message ID:
3D2C43FA.3888F4E6@guideguide.com
```Phil Carmody wrote:
>
> --- Jasper McCrea <jasper@guideguide.com> wrote:
> > Michael W Thelen wrote:
> > >
> > > On Wed, Jul 10, 2002 at 12:47:40PM +0100, Jasper McCrea wrote:
> > > > given a line number on the command line, print out that line
> > from
> > > > Pascal's triangle. Single space separated numbers, nothing but
> > a \n at
> > > > the end, you know the drill.
> > >
> > > Do the line numbers begin at 0 or 1?  Is it like this?
> > >
> > > line 0:       1
> > > line 1:      1 1
> > > line 2:     1 2 1
> > >
> >
> > I think line numbering will begin at 1. 0 would be too odd. And it
> > would
> > add a few characters to my solution :)
>
> (1+1)^0 =     1
> (1+1)^1 =    1+1
> (1+1)^2 =   1+2+1
> (1+1)^3 =  1+3+3+1
> (1+1)^4 = 1+4+6+4+1
>
> Not odd at all.

I was more thinking of the oddness of the zeroth (?) line of anything. I
said the line number is given on the command line. If you put it like you
did, then not odd. But I didn't.

Jasp
--
@a=0..63;g(o(\$_),a(\$_)?\$_<24?"w":\$_>39?"b":0:0)for@a;\$w=\$b=12;while(\$w&&\$b)
{\$z=!\$z if!\$r;\$i="
01234567\n";print\$i,(join"",map{(\$x,\$y)=o(\$_);(\$x?"":\$y)
..(a(\$_)?"\e[7m":"\e[27m").(g(o(\$_))||"
")."\e[27m".(\$x==7?"\$y\n":"")}@a),\$i
;\$z?&n:&c;g(\$f,\$g,(\$g==7&&\$z)||!(\$z||\$g)?uc&w:g(\$d,\$e));g(\$d,\$e,0);t(1)}sub
n{print"\$_xyxy?\n";(\$d,\$e,\$f,\$g)=split"",<>;&v||&n}sub t{
@t=(\$f>\$d?\$d+1
:\$d-1,\$g>\$e?\$e+1:\$e-1);if(\$s==4&&g(@t)&&lc(g(@t))ne&w){if(@_){g(@t,0);\$z?--
\$b:--\$w;&b}1}else{0}}sub
v{\$s=(\$d-\$f)**2;(lc(g(\$d,\$e))ne&w||\$s!=(\$e-\$g)**2
||g(\$f,\$g)||\$f>7||\$f<0||\$g>7||\$g<0||((\$z?\$e-\$g:\$g-\$e)>0)&&!(g(\$d,\$e)eq
uc&w
)||!(\$s==1||t())||(\$r?\$d!=\$c||\$e!=\$h:0))?0:1}sub
c{for(@a){(\$d,\$e)=o(\$_);if
(lc(g(o(\$_)))eq&w){for(@a){(\$f,\$g)=o(\$_);&t?return:push@q,[\$d,\$e,\$f,\$g]if&v
}}}(\$d,\$e,\$f,\$g)=@{\$q[\$#q]}}sub w{\$z?"w":"b"}sub
o{(\$_%8,int(\$_/8))}
sub a{(\$_%8+int(\$_/8))%2}sub
g{\$n=\$_+8*\$_;defined\$_?\$j[\$n]=\$_
:\$j[\$n]}sub
b{\$d=\$c=\$f;\$e=\$h=\$g;\$r=(grep{(\$f,\$g)=o(\$_);&v&&t()}@a)?1:0}
die\$w?"win":"lose"."\n"

```