[2022][ruby][4.x] cleanup

pull/1/head
Alpha Chen 1 year ago
parent 74d3bef510
commit e9093934cf
Signed by: alpha
SSH Key Fingerprint: SHA256:3fOT8fiYQG/aK9ntivV3Bqtg8AYQ7q4nV6ZgihOA20g

@ -1,6 +1,6 @@
p ARGF.read.lines(chomp: true)
.map { _1.split(?,) }
.map {|x| x.map { _1.split(?-).map(&:to_i) }}
.map {|(a,b),(x,y)| [(a..b), (x..y)] }
# .count {|a,b| (a.cover?(b.begin) && a.cover?(b.end)) || (b.cover?(a.begin) && b.cover?(a.end)) }
.count {|a,b| (a.cover?(b.begin) || a.cover?(b.end)) || (b.cover?(a.begin) || b.cover?(a.end)) }
p ARGF.read
.scan(/(\d+)-(\d+),(\d+)-(\d+)/)
.map { _1.map(&:to_i) }
.map {|a,b,c,d| [(a..b), (c..d)] }
# .count {|a,b| a.cover?(b) || b.cover?(a) } # part 1
.count {|a,b| a.minmax.any? { b.cover?(_1) } || b.minmax.any? { a.cover?(_1) }}

Loading…
Cancel
Save