Advertisement
here2share

# Weak_Random.py

Jun 24th, 2023 (edited)
793
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.38 KB | None | 0 0
  1. # Weak_Random.py
  2.  
  3. seed = 1
  4. counter = 0
  5. def Weak_Random(vmin=0, vmax=100):
  6.     global counter, seed
  7.     seed = str(vmax//2)+str(seed)+'1'
  8.     vmax -= vmin
  9.     while True:
  10.         counter += 1
  11.         rnd = (counter^counter*int(str(counter)+seed))%vmax+vmin
  12.         yield rnd
  13.        
  14. gen = Weak_Random(vmin=50, vmax=109)
  15. for _ in range(500):
  16.     print(next(gen))
  17. counter = 490
  18. for _ in range(10):
  19.     print(next(gen))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement