1
0
Fork 0

Puzzle du 15 décembre 2017

This commit is contained in:
Lucidiot 2017-12-15 07:09:36 +01:00
parent 13b531e34b
commit f8d1af84aa
No known key found for this signature in database
GPG Key ID: 63BD9482C29D0F64
1 changed files with 14 additions and 0 deletions

14
2017/15/gen.py Normal file
View File

@ -0,0 +1,14 @@
#!/usr/bin/env python3
def gen(value, factor, modulo=1):
while True:
value = (value * factor) % 2147483647
if value % modulo == 0:
yield value & 0xffff
# Generator starting values
A, B = 65, 8921
genA, genB = gen(A, 16807), gen(B, 48271)
print(sum(next(genA) == next(genB) for _ in range(40000000)))
genA, genB = gen(A, 16807, 4), gen(B, 48271, 8)
print(sum(next(genA) == next(genB) for _ in range(5000000)))