summaryrefslogtreecommitdiff
path: root/lib/AdventOfCode/Day3.rakumod
blob: 46aac011fb871da322a6bb494d6e71b6275a5ce3 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
use AdventOfCode::Utils;

sub minimum-distance($input1, $input2) {
    my $wire1 = Wire.new($input1);
    dd $wire1;
    my $wire2 = Wire.new($input2);

    for $wire1.lines -> $line1 {
        for $wire2.lines -> $line2 {
            if my $intersection = intersection($line1, $line2) {
                say "Manhattan distance of intersection $intersection: " ~ manhattan-distance(
                    Point.new, $intersection
                );
            }
        }
    }
}

sub MAIN('day3') is export(:main) {
    minimum-distance(
        "R8,U5,L5,D3",
        "U7,R6,D4,L4"
    );
}