Wow. This was a neat problem. I'd like to post my solution (which came in really abysmally) and MeowChow's solution, which was the leader till this weekend. Just reading this one game me a ton of new tricks.

I managed to get to 92 characters with the following:

map$j{join'',sort/./g}.=$_,sort<>;map{/^[^a]/&&print$'}sort map{(a..t) +[s!$/(?=.)! !g].$_}%j
I was miffed that I couldn't get to 80 or less, but it was better than the 120+ I originally had.

Then I looked at MeowChow's.

$o{_,sort/./g}=~s/.*/_$& $_/for sort<>;print/__ (.* )/for sort%o
And, yes, that carriage return after the .* is necessary. I'm like, Ouch! The tricks in this one.
  1. I'd been struggling to remove the join in my hashkey. I couldn't figure out how to force stringification on the sort without having it hit scalar context first. I completely forgot to look at multiple keys.
  2. I started in with the GRT so I could get everything to work with the default behavior of sort. The problem was that I was setting some letter, then having to remove that letter. That cost me, easily, 6+ characters. Instead, just concatenate some character as many times as you have words at the beginning, then strip that out later.

    The best thing about doing it this way is that you get to count while reading, instead of counting when preparing to write.

  3. I was stupid with the s!$/(?=.)! !g stuff. I forgot to use a carriage return within the substitution and didn't know how to use \b. *sighs*
For those curious why MeowChow didn't do something with $' instead of adding the carriage return in the capture, remember that doing it that way would require two map/for's, not just one.

------
We are the carpenters and bricklayers of the Information Age.

Don't go borrowing trouble. For programmers, this means Worry only about what you need to implement.


In reply to Re: TPR(0,2) Begins by dragonchild
in thread TPR(0,2) Begins by redsquirrel

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.