From 408c7a8b7dce5246a595b7737de6a1b7825a53b8 Mon Sep 17 00:00:00 2001 From: Nat Lasseter Date: Sun, 4 Dec 2022 12:41:13 +0000 Subject: Day 04 --- day04/part1.rb | 9 +++++++++ 1 file changed, 9 insertions(+) create mode 100644 day04/part1.rb (limited to 'day04/part1.rb') 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 -- cgit v1.2.1