X-Git-Url: https://www.fi.muni.cz/~kas/git//home/kas/public_html/git/?a=blobdiff_plain;f=2023%2F48.pl;fp=2023%2F48.pl;h=89bd982c7148d692c3fc03b330e440f2d371c5ec;hb=2f3400900f836b8b0b781bc3b0c9a380dd999b6d;hp=0000000000000000000000000000000000000000;hpb=cb7662a16eca1ff55e28338ef8ea7161224ac078;p=aoc.git diff --git a/2023/48.pl b/2023/48.pl new file mode 100755 index 0000000..89bd982 --- /dev/null +++ b/2023/48.pl @@ -0,0 +1,23 @@ +#!/usr/bin/perl -w + +use v5.38; + +my @stones = map { chomp; [ /-?\d+/g ] } <>; + +my @eq; +for my $stone (0 .. 2) { + my @st = @{ $stones[$stone] }; + for my $co (0 .. 2) { + my $c = $st[$co+3]; + my $d = $st[$co]; + push @eq, "a$co * t$stone + b$co = $c*t$stone + $d"; + } +} +my @vars; +push @vars, "a$_", "b$_", "t$_" for 0 .. 2; + +# Maple: +say "res := solve({\n\t", join(",\n\t", @eq), "\n},"; +say "\t[", join(", ", @vars), " ]"; +say ");"; +say "res[1][2]+res[1][5]+res[1][8];";