Puzzle du 15 décembre 2017
This commit is contained in:
parent
13b531e34b
commit
f8d1af84aa
|
@ -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)))
|
Loading…
Reference in New Issue