Beefy Boxes and Bandwidth Generously Provided by pair Networks
good chemistry is complicated,
and a little bit messy -LW
 
PerlMonks  

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

by petral (Curate)
on Jun 06, 2001 at 16:21 UTC ( #86182=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

Or 105:
print /^..\z/&("MNCAKSCOHINMOKTNVALARIDCTX SDE GAZ ORIL"=~/$_/| /FL|IA|KY|M[ADEIST]|N[DEHJY]|PA|[UV]T|W[AIVY]/) for qw(AK AL AR AZ CA CO CT DC DE FL GA HI IA ID IL IN KS KT KY LA MA MD ME MI MN MO MS MT NC ND NE NH NJ NM NV NY OH OK OR PA RI SC SD TN TX UT VA VT WA WI WV WY MY MNC .* ), " SD", "AZ\n"
(Dropping the inner parens around the or-chain and disregarding the state of NN which is not being honored today.)

OOPSDATE: Yep, matches if $_='.*' (see runriq immediately below and slightly to the right).  It needs /\Q$_/, as so often happens, which defeats the character savings.  I was looking at the \w as avoiding matching the spaces (which it also does).    (Oh, and thanks runriq and I'm sorry too!)
  p

Replies are listed 'Best First'.
Re: Re: Re: Golf challenge: match U.S. State names
by runrig (Abbot) on Jun 06, 2001 at 18:24 UTC
    Sorry, but your expression makes '.*' an honorary state :-)

    That's why dws uses '\w\w' instead of '..' in his answer.

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://86182]
help
Chatterbox?
[Corion]: Hah. I just had this idea for another EMACS backronym, but I still need to make it happen. "Eight Machines And Constantly Synching" - I envision a NodeJS+Kybernetes based infrastructure communicating between the syntax highlighter machine, the ...
[Corion]: ... screen render machine, the file store machine and five more (maybe for redundancy?), just to write print "Hello World"; ;)
[Corion]: Ah, maybe one machine could be the compiler host, which constantly compiles the Elisp to Javascript to serve to all the other machines running it...

How do I use this? | Other CB clients
Other Users?
Others chanting in the Monastery: (6)
As of 2018-04-26 11:26 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    Notices?