Please don't chortle, but the only machine I have available
right now is my Dad's creaky old Windows 98 box running
ActiveState 5.6.1 (I am on holidays).

My testing on this magnificent machine has uncovered some
flaws in some of the golf entries:

perl -p0 -e'$n=1+y|\n||/2;/(.*\n){$n}/;$_=$+'   (Yv2.0) 
perl -p0 -e'$n=1+y|\n||/2;($_)=/(.*\n){$n}/'    (japhy) 

These two fail for me (printing nothing) when run
with a file containing an odd number of lines.
Replacing 'y|\n||/2' with 'y|\n||>>1' fixes them,
at the cost of one stroke.

perl -0naF'\n' -e'print @F[@F>>1]'              (dave0) 
perl -0naF'\n' -e'print $F[@F/2]'               (dave0 #2) 
perl -0paF'\n' -e'$_=$F[@F/2]'                  (mjassels) 

Due to a split idiosyncrasy, these three fail with
a test file containing multiple trailing blank lines.

Yannick's last solution:

perl -p0 -e'$_=$1while/\n(.*)\n/s'      (Yv3.2)

prints two centre lines when presented with a
test file containing an odd number of lines.

I think this leaves the current golf leader as
Eugene on 37 strokes (35 under par) with:

perl -p0 -e'$_=(/(.*\n)/g)[y|\n||/2]'

Eugene, I like this solution (and I think we should
have an 'open' category in any case), but there
may be a protest if someone suggests this solution
violates the 'no array' requirement.

Andrew.

Reply via email to