Skip to content

Instantly share code, notes, and snippets.

@lizmat
Created December 15, 2017 11:31
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save lizmat/d8da65dfea8d223f4c673f6e61656a25 to your computer and use it in GitHub Desktop.
Save lizmat/d8da65dfea8d223f4c673f6e61656a25 to your computer and use it in GitHub Desktop.
adventofcode #15 part of solution?
sub generator(int $init, int $times, int $modulo) {
my int $value = $init;
-> { ($value = ($value * $times) % $modulo) +& 65535 }
}
my $a = generator(65, 16807, 2147483647);
my $b = generator(8921, 48271, 2147483647);
my int $count;
++$count if $a() == $b() for ^40_000_000;
say $count;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment