From f72322eeca75367f74e90833485d5d27ed79df82 Mon Sep 17 00:00:00 2001 From: "Jan \"Yenya\" Kasprzak" Date: Wed, 6 Dec 2023 06:22:39 +0100 Subject: [PATCH] Day 6: too slow --- 2023/11.pl | 20 ++++++++++++++++++++ 2023/12.pl | 14 ++++++++++++++ 2 files changed, 34 insertions(+) create mode 100755 2023/11.pl create mode 100755 2023/12.pl diff --git a/2023/11.pl b/2023/11.pl new file mode 100755 index 0000000..f00d585 --- /dev/null +++ b/2023/11.pl @@ -0,0 +1,20 @@ +#!/usr/bin/perl -w + +use v5.38; + +my @times =<>=~ /(\d+)/g; +my @dists =<>=~ /(\d+)/g; + +my $res = 1; +while (@times) { + my $t = shift @times; + my $d = shift @dists; + my $n; + for my $t1 (1 .. $t-1) { + my $d1 = ($t-$t1)*$t1; + $n++ if ($d1 > $d); + } + $res *= $n; +} + +say $res; diff --git a/2023/12.pl b/2023/12.pl new file mode 100755 index 0000000..3b5ae4a --- /dev/null +++ b/2023/12.pl @@ -0,0 +1,14 @@ +#!/usr/bin/perl -w + +use v5.38; + +my $t = join('', <> =~ /\d+/g); +my $d = join('', <> =~ /\d+/g); + +my $n; +for my $t1 (1 .. $t-1) { + my $d1 = ($t-$t1)*$t1; + $n++ if $d1 > $d; + # say "$t1 $n" if $t1 % 10_000 == 0; +} +say $n; -- 2.43.5