Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/usr/bin/perl
- use strict;
- use warnings;
- $| = 1;
- my @list = map { chomp; split /,/ } <>;
- my %hash;
- foreach my $t (0 .. $#list - 1) {
- $hash{$list[$t]} = $t + 1;
- }
- foreach my $t ($#list + 1 .. 30000000) {
- my $next = $list[-1];
- print "[$t] $next \r" if ($t % 10000 == 0);
- print "[$t] $next \n" if ($t == 2020);
- push( @list, (exists $hash{ $next }) ? $t - $hash{ $next } : 0 );
- $hash{ $next } = $t;
- }
- print "\n";
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement