DEV Community

Discussion on: Daily Coding Puzzles - Nov 11th - Nov 16th

Collapse
 
choroba profile image
E. Choroba

The Perl solution I submitted back in 2017:

#!/usr/bin/perl
use warnings;
use strict;
use feature qw{ say };

my $test_count = <>;
for my $test_case (1 .. $test_count) {
    my ($destination, $horse_count) = split ' ', <>;
    my $other_max = 0;
    for my $horse (1 .. $horse_count) {
        my ($position, $max_speed) = split ' ', <>;
        my $speed = ($destination - $position) / $max_speed;
        $other_max = $speed if $other_max < $speed;
    }
    say "Case #$test_case: ", $destination / $other_max;
}