#!/usr/bin/perl -w

use v5.30;
use strict;

my @pts;
my @vel;
while (<>) {
	my ($x, $y, $dx, $dy) = /(-?\d+)/g;
	push @pts, [ $x, $y ];
	push @vel, [ $dx, $dy ];
}

$; = ',';
my $printed;
my $count;

while (1) {
	my %map;
	my ($minx, $miny, $maxx, $maxy);
	for my $i (0 .. $#pts) {
		my $pt = $pts[$i];
		my $ve = $vel[$i];
		$pt->[$_] += $ve->[$_] for 0 .. 1;
		$maxx = $pt->[0] if !defined $maxx || $maxx < $pt->[0];
		$maxy = $pt->[1] if !defined $maxy || $maxy < $pt->[1];
		$minx = $pt->[0] if !defined $minx || $minx > $pt->[0];
		$miny = $pt->[1] if !defined $miny || $miny > $pt->[1];
		$map{$pt->[0],$pt->[1]}++;
	}
	$count++;
	my $dim = $maxx-$minx + $maxy-$miny;
	if ($dim < 150) {
		say "count=$count :";
		for my $y ($miny .. $maxy) {
			for my $x ($minx .. $maxx) {
				print $map{$x,$y} ? '#' : '.';
			}
			print "\n";
		}
		$printed = 1;
	} elsif ($printed) {
		last;
	}
	say "dim=$dim\n";
}


	


