Swapping heightmaps to depthmaps

Golfscript, 42 chars

n%{n*~]}%zip:|[]*$),{:);n|{{)>},,}%}%-1%\;

results

$ golfscript 2657.gs < 2657-1.txt 
0001
1012
1112
1212
2222
3323

$ golfscript 2657.gs < 2657-2.txt 
01
12
22

$ golfscript 2657.gs < 2657-3.txt 
010
211
322

Ruby 1.9, 102 characters

f=$<.map{|g|[*g.chop.bytes]}
f.flatten.max.downto(49){|j|puts f.transpose.map{|n|n.count{|r|r>=j}}*""}

Passes all testcases.


Windows PowerShell, 108 111 114

(($i=@($input))-split''|sort)[-1]..1|%{$h=$_
-join(1..$i[0].Length|%{$x=$_-1
@($i|?{"$h"-le$_[$x]}).count})}

Passes all test cases.

Tags:

Code Golf