in reply to Re: Golf - now for the Sentencing.
in thread Golf - now for the Sentencing.

But this solution doesn't work when
$_='tHere are CAPITAL leTters iNterSpersed';
I believe grep wants everything to be lowercased other than beginning of sentences and single I's. Adding an lc and using your regex, this code
# Test: $_='tHere is more than one way to do it. Also, i am just ANOTHER golfer.'; # 1 2 3 #234567890123456789012345678901 $_=lc;s;^.|\bi\b|\.\s*.;\U$&;g; # Proof print
should output this
There is more than one way to do it. Also, I am just another golfer.

Replies are listed 'Best First'.
Re: Re: Re: Golf - now for the Sentencing.
by Sidhekin (Priest) on Apr 23, 2002 at 08:47 UTC

    I believe grep wants everything to be lowercased other than beginning of sentences and single I's.

    Well, that's what I get for reading the rules only, and not his solution. Clearly, the intent of that code is to lowercase everything else. I cannot beat 31, and nor does japhy — his code is identical to yours, except for your trailing ";" and variant delimiters (and if he can ignore the test harness, so can you).

    (But I would have found the same! :-)

    Now, of course the lc version is shorter and therefore better, but I could not leave this without some code, now could I? This is at 35 strokes; the best remains at 31.

    # 3456789 123456789 123456789 12345 s/(^.|\.\s*.|\bi\b)|(.)/\U$1\L$2/g;

    The Sidhekin
    print "Just another Perl ${\(trickster and hacker)},"