On Thu, 17 Jun 2004, why the lucky stiff wrote: > Ralf Mler wrote: > > >tried with Hash instead of Array: > >ram@lilith:~/src/ruby$time ruby -e 'str=STDIN.gets; h=Hash.new(); (0..9).each > >{|i| h[i.to_s] = 0}; (0..str.length-1).each {|i| h[str[i..i]] += 1 }; h.each > >{|k,v| print "#{k} #{v}\n"} ' < pi.out | sort > > > > > why@stungun$ time ruby -n -e 'c={};$_.each_byte{|b|c[b]||=0; c[b]+=1}; > c.sort.each {|k,v| puts "#{k - ?0} #{v}"}' < pi.out > > same idea as yours. just runs 3x swift. I typo a lot, so no command line. Maybe 150-170x speed of OP. n = STDIN.gets tot = 0 9.times do |i| c = n.count(i.to_s) tot += c puts "#{i} #{c}" end puts "9 #{n.size - tot}" -- Relm