Beefy Boxes and Bandwidth Generously Provided by pair Networks
Clear questions and runnable code
get the best and fastest answer
 
PerlMonks  

Re: Re: Golf challange: match U.S. State names

by dws (Chancellor)
on Jun 06, 2001 at 22:13 UTC ( #86328=note: print w/replies, xml ) Need Help??


in reply to Re: Golf challange: match U.S. State names
in thread Golf challange: match U.S. State names

Now 108
/^\w\w\z/&("MNCAKSCOHINMOKTNVALARIDCTX SDE GAZ ORIL IAKY"=~/$_/| /(FL|M[ADEIST]|N[DEHNJY]|PA|[UV]T|W[AIVY])/)
Another stoke off by adding a redundant check for Alaska, which allowed me to move Iowa and Kentucky out of the regexp and into the (more compact) string.

This suggests that there's a lesson in here about how a bit of redundancy in data can lead to more compact representations. I think we often hear problems like "match every state and nothing else" as "match every state exactly once, and nothing else."

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://86328]
help
Chatterbox?
[ww]: or a lot more than (22*2) for /me
[ww]: er -- senior cognitive deficiency: ((22+(22*2))
[ww]: (but pls don't s/senior/senile/ ... not yet
[karlgoethebier]: A bit more audience now: The Impact of Information Sources on Code Security Very interesting IMHO...
[karlgoethebier]: ..it's about copy & paste ;-)
[ww]: Wonder what IEEE would have thought w/survey based on PM/perl
[ww]: s/thought/found/
[erix]: that title is a broken* sentence, no? But maybe that's deliberate
[karlgoethebier]: ww:My first thought, to be honest...

How do I use this? | Other CB clients
Other Users?
Others wandering the Monastery: (10)
As of 2017-09-25 14:39 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    During the recent solar eclipse, I:









    Results (280 votes). Check out past polls.

    Notices?