adventofcode/2017/15/1.pl
2017-12-28 12:14:51 -05:00

19 lines
268 B
Perl

use 5.20.0;
use List::AllUtils qw/ pairgrep /;
my @v = ( 679,771 );
my $mask = 2**16 - 1;
my $match;
for ( 1..40_000_000 ) {
@v = ( 16807 * $v[0], 48271 * $v[1] );
$_ %= 2147483647 for @v;
$match += ($v[0] & $mask) == ($v[1] & $mask);
}
say $match;