Front page | perl.fwp |
Postings from January 2002
Re: even.pl solutions
Thread Previous
|
Thread Next
From:
Stephen Turner
Date:
January 29, 2002 01:51
Subject:
Re: even.pl solutions
Message ID:
Pine.LNX.3.96.1020129093824.1634A-100000@gentoo
On Tue, 29 Jan 2002, Peter Makholm wrote:
>
> > -p for$v(aeiouy=~/./g){$_ x=1&~eval"$.|~y///c|y/$v//"} 54 jason
> > -nl 1&eval join qw(//|y/ $.|y/a e i o u y //c)or print 54 makho
> > -nl $x=$.%2;map{$x^=4*2**index aeiouy,$_}/./g;$x||print 55 turn
>
> Three quite different solutions.
Agreed. Although annoyingly, I now realise I could have lost a stroke and
tied by using
$x^=4*2**index aeiouy,$_ for/./g
as the middle expression. For some reason I forgot that "for" could come
after the statement. I can see I need to go and practice my putting some
more.
Oh, also 7-9*index instead of 4*2**index loses a stroke and passes the test
suite but doesn't solve the problem. (In a mail to Andrew, I called this my
"golf buggy" solution :-). The assiduous reader might like to find a word
that it gives the wrong answer on. If you can be bothered.
> I really like Stephens solution iot
> counts each of the wovels individually much nicer than anything I
> thought of.
Well, thank you. But I was just thinking I liked yours! The idea of writing
a program to write a program to solve the problem somehow passed me by...
Perhaps it depends whether you prefer transparency or obscurity. :-)
Actually, I liked my earlier (66) effort better. Not very short, but I
thought it was cute. It kept explicitly counting the newline at the end of
the line in order to make all the counts odd; then multiply them together
and they stay odd.
--
Stephen Turner, Cambridge, UK http://homepage.ntlworld.com/adelie/stephen/
"This is Henman's 8th Wimbledon, and he's only lost 7 matches." BBC, 2/Jul/01
Thread Previous
|
Thread Next