This is a solution to Advent of Code 2022 day 4, written in Raku.
https://adventofcode.com/2022/day/4
Part One
In how many assignment pairs does one range fully contain the other?
say [+] '4-input.txt'.IO.lines.map({
my Int ($a, $b, $x, $y) = .comb(/\d+/)>>.Int;
my @a = $a..$b;
my @b = $x..$y;
@a (<=) @b || @b (<=) @a;
});
500
Part Two
In how many assignment pairs do the ranges overlap?
say [+] '4-input.txt'.IO.lines.map({
my Int ($a, $b, $x, $y) = .comb(/\d+/)>>.Int;
my @a = $a..$b;
my @b = $x..$y;
?(@a (&) @b)
});
815