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

Re^2: Homework Golf

by Athanasius (Archbishop)
on Dec 04, 2013 at 04:17 UTC ( #1065534=note: print w/replies, xml ) Need Help??


in reply to Re: Homework Golf
in thread Homework Golf

The second solution has a problem: each chop reduces $_ by one character until $_ is the empty string — which is what gets printed when $n is 65. My fix has 59 characters:

#23456789_123456789_123456789_123456789_123456789_123456789 perl -nlE"$w=$_;$n=0;$n+=ord(chop)-96while$_;$n==65&&say$w" words.txt

But the first solution can be reduced a little to 54 characters:

#23456789_123456789_123456789_123456789_123456789_1234 perl -nlE"$n=0;map$n+=$_-96,unpack'C*',$_;$n==65&&say" words.txt

:-)

Athanasius <°(((><contra mundum Iustus alius egestas vitae, eros Piratica,

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others having an uproarious good time at the Monastery: (3)
As of 2021-10-27 16:06 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    My first memorable Perl project was:







    Results (94 votes). Check out past polls.

    Notices?