summaryrefslogtreecommitdiff
path: root/lib/AdventOfCode/Day3.rakumod
diff options
context:
space:
mode:
Diffstat (limited to 'lib/AdventOfCode/Day3.rakumod')
-rw-r--r--lib/AdventOfCode/Day3.rakumod24
1 files changed, 24 insertions, 0 deletions
diff --git a/lib/AdventOfCode/Day3.rakumod b/lib/AdventOfCode/Day3.rakumod
new file mode 100644
index 0000000..46aac01
--- /dev/null
+++ b/lib/AdventOfCode/Day3.rakumod
@@ -0,0 +1,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"
+ );
+}