27 lines
585 B
Python
27 lines
585 B
Python
#!/usr/bin/env python3
|
|
|
|
# World's worst random number generator
|
|
def xorshift32(x):
|
|
x = x ^ (x << 13) & 0xffffffff
|
|
x = x ^ (x >> 17) & 0xffffffff
|
|
x = x ^ (x << 5) & 0xffffffff
|
|
return x & 0xffffffff
|
|
|
|
def get_rand(x):
|
|
out = 0
|
|
for i in range(32):
|
|
x = xorshift32(x)
|
|
if (x & 1) == 1:
|
|
out = out | (1 << i)
|
|
return out & 0xffffffff
|
|
|
|
def get_bit(x):
|
|
return (256 * (x & 7)) + (x >> 3)
|
|
|
|
def main():
|
|
init = 1
|
|
for i in range(20):
|
|
init = get_rand(init)
|
|
print("{:08x}".format(init))
|
|
|
|
main() |