Slashdot Q&A

Problem: Write a program which takes a string on standard input, and reports the most frequently occurring characters in the string.

Solution:

#!/usr/bin/perl -w @c=split /[n.]*/,;foreach$c(@c){$n{$c}=$n{$c}?$n{$c}+1:1;} foreach$x(sort{$n{$b}$n{$a}}keys%n){print"$n{$x} x $xn"};

I just couldn’t stop myself…