From: Jan "Yenya" Kasprzak Date: Wed, 6 Dec 2023 05:22:39 +0000 (+0100) Subject: Day 6: too slow X-Git-Url: https://www.fi.muni.cz/~kas/git//home/kas/public_html/git/?p=aoc.git;a=commitdiff_plain;h=f72322eeca75367f74e90833485d5d27ed79df82 Day 6: too slow --- 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;