Skip to content

Commit 49ac72e

Browse files
committed
day 4
1 parent 772cf7d commit 49ac72e

File tree

3 files changed

+1014
-0
lines changed

3 files changed

+1014
-0
lines changed

04/a.rb

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
File
2+
.readlines("04/input.txt")
3+
.select do |line|
4+
a, b, c, d = line.scan(/\d+/).map(&:to_i)
5+
(a >= c && b <= d) || (c >= a && d <= b)
6+
end
7+
.then { |contains| puts contains.count }

04/b.rb

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
File
2+
.readlines("04/input.txt")
3+
.select do |line|
4+
a, b, c, d = line.scan(/\d+/).map(&:to_i)
5+
c < a ? d >= a : c <= b
6+
end
7+
.then { |overlaps| puts overlaps.count }

0 commit comments

Comments
 (0)