Beefy Boxes and Bandwidth Generously Provided by pair Networks
No such thing as a small change
 
PerlMonks  

Re: PGA Golf, Round 1

by petral (Curate)
on May 25, 2001 at 18:08 UTC ( #83312=note: print w/ replies, xml ) Need Help??


in reply to PGA Golf, Round 1

I did slightly better in a couple of places, so probably wrong. I'll submit it now, before better solutions show up for everything. (Corrected holes 3 and 4 as per more-careful-readers-of-specs.)

# hole 1: 16 perl -le 'sub h1 {(pop=~/\w+/g)[4]}' -e'print h1"abc ,., de f g + hi jk"' # hole 2: 20 perl -e' goto TPC' # hole 3: 19 perl -le 'sub h3 {pop=~/^(.+?)\1+\z/s}' -e'print h3 join" ",qw(hihi +hihi)' # hole 4: 19 perl -le 'sub h4 {split"",pack"H*",@_}' -e'$,=$";print h4"68696C6f" +' # hole 5: 22 XXX see below: perl -le 'sub h5 {$_<$x or$x=$_ for@_;$x}' -e'print h5(3,5,2,8,7)' # hole 6: 38 perl -le 'sub h6 {grep{s/.//}sort map{/[aeiou]/;$&.$_}@_}' \ -e'$,=$";print h6 qw(book eel hi huge i pe +a wrap)'
oopsdate: Yes, 5 doesn't work w/o priming the temporary (which makes it 30 chars).
So, here's an overly golfish version that I managed to trim to 32:
perl -le'sub x {$_[-1]<$_[0]?pop:shift;$#_?&x:@_}' -e'print x(-3,-5,-2 +,-8,-7)'
(And yes, by the time I posted them, the solutions were all pretty much established. jmcnamara said he wasn't posting answers for a week, so it's a guess between not posting 'spoilers' and getting 'rep' -- especially when others are updating as you collect and cut and paste.  --  Anyway, it is kinda neat that, at least for these first few, the straightforward solutions are the best.)

  p


Comment on Re: PGA Golf, Round 1
Select or Download Code

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others about the Monastery: (18)
As of 2015-07-01 19:45 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The top three priorities of my open tasks are (in descending order of likelihood to be worked on) ...









    Results (17 votes), past polls