From 8f35c2dc6516303ae0786d08cc7912ccb8218f78 Mon Sep 17 00:00:00 2001 From: Matias Linares Date: Tue, 10 Dec 2019 09:29:12 -0300 Subject: Initial commit --- lib/AdventOfCode/Day3.rakumod | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) create mode 100644 lib/AdventOfCode/Day3.rakumod (limited to 'lib/AdventOfCode/Day3.rakumod') 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" + ); +} -- cgit v1.2.3-70-g09d2