Skip to content

Instantly share code, notes, and snippets.

@eiel
Created March 4, 2015 14:41
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save eiel/ffe292eceb97c9290576 to your computer and use it in GitHub Desktop.
Save eiel/ffe292eceb97c9290576 to your computer and use it in GitHub Desktop.
P3なPPM形式の画像の各色の数を数える。
ppmtype = ARGF.readline.chop
width, height = *(ARGF.readline.chop.split)
max = ARGF.readline
hash = Hash.new(0)
ARGF.read.split.map(&:to_i).each_slice(3) do |color|
hash[color] += 1
end
hash.each do |k,v|
puts "#{k} #{v}"
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment