From 43ab0a3a7a1e095f5f33f224ce73c413f49e156c Mon Sep 17 00:00:00 2001 From: Nat Lasseter Date: Sun, 2 Dec 2018 12:41:05 +0000 Subject: Initial commit --- day02/part1 | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) create mode 100755 day02/part1 (limited to 'day02/part1') 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 -- cgit v1.2.3