Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl-Sensitive Sunglasses
 
PerlMonks  

Re: Re: Golf - now for the Sentencing.

by redsquirrel (Hermit)
on Apr 22, 2002 at 13:20 UTC ( [id://161044]=note: print w/replies, xml ) Need Help??


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)},"

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://161044]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others having a coffee break in the Monastery: (4)
As of 2024-04-25 09:33 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found