aboutsummaryrefslogtreecommitdiff
path: root/day02/part1
blob: dca8ec20d1b5720bc180f32a9f739b603c830e09 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
#!/usr/bin/env ruby

class Integer
	def two?
		self == 2
	end
	def three?
		self == 3
	end
end

input = $stdin.readlines.map(&:chomp)

twos = 0
threes = 0

input.each do |i|
	hash = Hash.new(0)
	i.chars.each do |c|
		hash[c] += 1
	end
	twos += 1 if hash.values.map(&:two?).any?
	threes += 1 if hash.values.map(&:three?).any?
end

puts twos * threes