On topic: The Wednesday Challenge

Paul Johnson paul at pjcj.net
Wed Aug 15 15:40:59 BST 2007


On Wed, Aug 15, 2007 at 03:01:00PM +0100, Andy Armstrong wrote:

> Given a 64 Mbyte file containing random binary data write a perl  
> program such that
> 
> $ perl myprog.pl < 64m.bin > 64m.sorted.bin
> 
> outputs a file 64m.sorted.bin with all the bytes sorted in ascending  
> order. Marks will be given for speed, brevity and parsimonious use of  
> memory.

$/=\1;$c{$_}++while<>;print$_ x$c{$_}for sort keys%c

-- 
Paul Johnson - paul at pjcj.net
http://www.pjcj.net


More information about the london.pm mailing list