diff options
author | Nat Lasseter <user@4574.co.uk> | 2022-12-04 12:41:13 +0000 |
---|---|---|
committer | Nat Lasseter <user@4574.co.uk> | 2022-12-04 12:41:13 +0000 |
commit | 408c7a8b7dce5246a595b7737de6a1b7825a53b8 (patch) | |
tree | 49976281d51f0ac58d6c3aed3817bf302ca333ab /day04/part1.rb | |
parent | c62e6e28ad065948557aea88958631462a42b1ec (diff) |
Day 04
Diffstat (limited to 'day04/part1.rb')
-rw-r--r-- | day04/part1.rb | 9 |
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 |