--- /dev/null
+#!/usr/bin/perl
+
+use v5.30;
+use strict;
+
+my (@acc, @vel, @pos);
+while (<>) {
+ my (@l) = /(-?\d+)/g;
+ push @pos, [ splice(@l, 0, 3) ];
+ push @vel, [ splice(@l, 0, 3) ];
+ push @acc, [ splice(@l, 0, 3) ];
+}
+
+my %destroyed;
+for (1 .. 1_000) {
+ my (@nvel, @npos);
+ my %pos_now;
+ for my $i (0 .. $#acc) {
+ my @v;
+ push @v, $vel[$i][$_] + $acc[$i][$_] for 0 .. 2;
+ push @nvel, \@v;
+ my @p;
+ push @p, $pos[$i][$_] + $v[$_] for 0 .. 2;
+ push @npos, \@p;
+ if (!$destroyed{$i}) {
+ my $key = join(',', @p);
+ if ($pos_now{$key}) {
+ $destroyed{$pos_now{$key}} = 1;
+ $destroyed{$i} = 1;
+ say "$_ destroyed $i because of $pos_now{$key} at $key";
+ } else {
+ $pos_now{$key} = $i;
+ }
+ }
+ }
+ @vel = @nvel;
+ @pos = @npos;
+}
+
+say $#acc - keys %destroyed;
+