#!/usr/bin/perl use v5.35.0; my $width = 101; my $height = 103; my $steps = 100; my $qx = ($width - 1) / 2; my $qy = ($height - 1) / 2; my ($q1, $q2, $q3, $q4); while (<>) { if (/p=(-?\d+),(-?\d+) v=(-?\d+),(-?\d+)/) { my ($px, $py, $vx, $vy) = ($1, $2, $3, $4); my $fx = ($px + $vx * $steps) % $width; my $fy = ($py + $vy * $steps) % $height; $q1 += ($fx < $qx && $fy < $qy); $q2 += ($fx > $qx && $fy < $qy); $q3 += ($fx < $qx && $fy > $qy); $q4 += ($fx > $qx && $fy > $qy); } } say $q1 * $q2 * $q3 * $q4;