summaryrefslogtreecommitdiff
path: root/lib/AdventOfCode/Day3.rakumod
diff options
context:
space:
mode:
authorMatias Linares <matiaslina@gmail.com>2019-12-10 09:29:12 -0300
committerMatias Linares <matiaslina@gmail.com>2019-12-10 09:29:12 -0300
commit8f35c2dc6516303ae0786d08cc7912ccb8218f78 (patch)
treef27e82ddd3d7044e19d964345e2991d5cbf67f00 /lib/AdventOfCode/Day3.rakumod
downloadadvent-of-code-2019-8f35c2dc6516303ae0786d08cc7912ccb8218f78.tar.gz
Initial commit
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"
+ );
+}