diff options
author | Nat Lasseter <user@4574.co.uk> | 2018-12-02 12:41:05 +0000 |
---|---|---|
committer | Nat Lasseter <user@4574.co.uk> | 2018-12-02 12:41:05 +0000 |
commit | 43ab0a3a7a1e095f5f33f224ce73c413f49e156c (patch) | |
tree | 1d4bfdb3385562511231f4389e29ca2279a916b1 /day02/part1 |
Initial commit
Diffstat (limited to 'day02/part1')
-rwxr-xr-x | day02/part1 | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/day02/part1 b/day02/part1 new file mode 100755 index 0000000..dca8ec2 --- /dev/null +++ b/day02/part1 @@ -0,0 +1,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 |