aboutsummaryrefslogtreecommitdiff
path: root/day04/part1.rb
diff options
context:
space:
mode:
Diffstat (limited to 'day04/part1.rb')
-rw-r--r--day04/part1.rb9
1 files changed, 9 insertions, 0 deletions
diff --git a/day04/part1.rb b/day04/part1.rb
new file mode 100644
index 0000000..529572c
--- /dev/null
+++ b/day04/part1.rb
@@ -0,0 +1,9 @@
+pairs = $stdin.readlines.map { |line|
+ line.strip.split(?,).map { |range|
+ Range.new(*range.split(?-).map(&:to_i))
+ }
+}
+
+puts pairs.select { |a, b|
+ a.cover?(b) || b.cover?(a)
+}.count