#!/usr/bin/perl use warnings; use strict; $#ARGV == 5 or die "usage: $0 my_x my_y my_speed attacker_x attacker_y attacker_speed\n"; my ($my_x, $my_y, $my_v, $att_x, $att_y, $att_v) = @ARGV; my $d = sqrt(($my_x - $att_x)**2 + ($my_y - $att_y)**2); my $my_t = 3600.*$d/$my_v; my $att_t = 3600.*$d/$att_v; printf("attacker travel time: %.2f seconds\n", $att_t); printf("your travel time: %.2f seconds\n", $my_t); my $before = "before"; my $launch_t = $my_t - $att_t; if ($launch_t < 0) { $before = "after"; $launch_t = -$launch_t; } my $launch_min = int($launch_t / 60); my $launch_sec = $launch_t - 60*$launch_min; printf("launch at %.2f seconds (%.0f:%05.2f) $before their attack lands\n", $launch_t, $launch_min, $launch_sec);