Coincidence, I assure you. It was an error when I golfified my
original solution, which was structured a little differently
internally allowing for the larger amount of data stored within the hash.
Though it is funny that it worked out perfectly. The example I used was one that I was working through by hand on paper just to make sure it matched.
Perhaps this is more appropriate:
sub f {
%r=@_;map{$m{$_}={map{$m{$_}||={};$_=>1}@{$r{$_}}}}keys%r;
reverse sort{$m{$b}{$a}-$m{$a}{$b}}keys%m;
}
Which is an increasingly disappointing 101 characters.
Thanks for pointing out the nature of my delusions.
I'm hoping that this isn't more complicated than, say,
(Golf) Shortest Graph Distance.
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: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.