这种神奇的技能是怎样做到的

再补一个Python 2.7的答案:import randomrandom.seed(387306269)print \u0026gt;\u0026gt;\u0026gt; 所以下一个数是43.感觉应该是穷举的。General notes on the underlying Mersenne Twister core generator:* The period is 2**19937-1.* It is one of the most extensively tested generators in existence.* Without a direct way to compute N steps forward, the semantics of jumpahead(n) are weakened to simply jump to another distant state and rely on the large period to avoid overlapping sequences.* The random() method is implemented in C, executes in a single Python step, and is, therefore, threadsafe.以上是random.py内的注释,其核心是调用c程序写得梅森旋转法生成的伪随机数,感觉不大可能是从结果逆推的。我自己写了一段代码,算出了2个seed,大概8分多钟。import randomfrom multiprocessing import Processfrom datetime import datetimestart = datetime.now()def guess_number(module): r = random.Random() seed = module while True: r.seed(seed) if r.randint(3, 48) == 3 and r.randint(3, 48) == 8 and r.randint(3, 48) == 12 \\ and r.randint(3, 48) == 48 and r.randint(3, 48) == 29: print \u0026#39;%d %s\u0026#39; % (seed, datetime.now() - start) seed += 8if __name__ == \u0026#39;__main__\u0026#39;: for i in range(8): process = Process(target=guess_number, args=(i,)) process.start()
■网友
* Python uses the Mersenne Twister as the core generator.* The Mersenne Twister is a pseudorandom number generator (PRNG).* The PRNG-generated sequence is not truly random, because it is completely determined by a relatively small set of initial values, called the PRNG\u0026#39;s seed (which may include truly random values).


    推荐阅读