Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/usr/bin/perl
- use strict;
- use warnings;
- my $time = <>; chomp $time;
- my @buses = grep { $_ ne 'x' } map { chomp; split /,/ } <>;
- my %next = map { $_ => ($_ - $time % $_) } @buses;
- my $part1;
- foreach my $k (sort { $next{$a} <=> $next{$b} } keys %next) {
- $part1 //= $k * $next{$k};
- }
- print "Part 1: $part1\n";
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement