Beefy Boxes and Bandwidth Generously Provided by pair Networks
more useful options
 
PerlMonks  

Re: Homework Golf

by oiskuu (Hermit)
on Dec 04, 2013 at 07:19 UTC ( [id://1065547]=note: print w/replies, xml ) Need Help??


in reply to Homework Golf

Um, the perl -nle'' count as 11? If so:

42
(Lowercase dictionary.)

perl -lnE'unpack("%a*")-65-96*length||say'
45
(Lowercase dictionary.)
perl -lne'65+length()*96-unpack"%a*"or print'
50
perl -lne'65+length()*96-unpack"%a*",lc or print'

Note: I added the say version following Athanasius's example.

Dec 05: x-d the readmore tags. Once more as above, using Abigail's Horror:

#23456789_123456789_123456789_123456789_ perl -lnE'65+96*y///c-unpack"%a*"or say'

Replies are listed 'Best First'.
Re^2: Homework Golf
by eyepopslikeamosquito (Archbishop) on Dec 04, 2013 at 10:22 UTC
      And now I have to live the rest of my life knowing what that is, so thanks for that.
Re^2: Homework Golf
by Tux (Canon) on Dec 04, 2013 at 07:26 UTC

    Which can be shortened to modern perl:

    36 perl -nE'65+length()*96-unpack"%a*",lc or say'

    Enjoy, Have FUN! H.Merijn
      Except... -l option is necessary for otherwise \n is a problem.

      Update: Tux(20+21+24) == 65 :-)

      I love this one. Took me ten minutes and a command line to take it apart and grok it. Awesome.

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others taking refuge in the Monastery: (5)
As of 2024-04-19 15:26 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found