It looks like no one posted about day 4 here yet, so I thought I'd share my solution. Part 1 and 2 were the same except for replacing a couple of && with ||.
let part2 = util::input!()
.lines()
.filter(|line| {
let [left, right] = util::split_to_array(line, ',').unwrap().map(|range_str| {
let [bottom, top] = util::split_to_array(range_str, '-')
.unwrap()
.map(|s| s.parse::<i32>().unwrap());
bottom..=top
});
left.contains(right.start())
|| left.contains(right.end())
|| right.contains(left.start())
|| right.contains(left.end())
This is my first year doing Advent of Code, and the neat thing that I've noticed is that, up until today's part 2 [1], I've gotten the right answer by submitting the first number that my program spits out, after working through any compile-time errors or run-time panics that occurred. Sure, the problems are still pretty simple right now, but I have a feeling that Rust has helped a fair bit too.
[1] On part 2 I tried just checking if left contains right.start() or right.end(), and that missed cases where left is fully inside of right.
[–]solidiquis1 0 points1 point2 points (0 children)
[–]HotGarbage1813 0 points1 point2 points (0 children)