<s> from browser import window , alert <EOL> def _randint ( a , b ) : <EOL> return int ( window . Math . random ( ) * ( b - a + <NUM_LIT:1> ) + a ) <EOL> def _rand_with_seed ( x , rand_obj ) : <EOL> degrees = rand_obj . _state % <NUM_LIT> <EOL> x = window . Math . sin ( degrees / ( <NUM_LIT:2> * window . Math . PI ) ) * <NUM_LIT> <EOL> if not hasattr ( rand_obj , '<STR_LIT>' ) : <EOL> rand_obj . incr = <NUM_LIT:1> <EOL> rand_obj . _state += rand_obj . incr <EOL> return x - window . Math . floor ( x ) <EOL> def _urandom ( n , rand_obj = None ) : <EOL> """<STR_LIT>""" <EOL> if rand_obj is None or rand_obj . _state is None : <EOL> randbytes = [ _randint ( <NUM_LIT:0> , <NUM_LIT:255> ) for i in range ( n ) ] <EOL> else : <EOL> randbytes = [ ] <EOL> for i in range ( n ) : <EOL> randbytes . append ( int ( <NUM_LIT> * _rand_with_seed ( i , rand_obj ) ) ) <EOL> return bytes ( randbytes ) <EOL> class Random : <EOL> """<STR_LIT>""" <EOL> VERSION = <NUM_LIT:3> <EOL> def __init__ ( self , x = None ) : <EOL> """<STR_LIT>""" <EOL> self . _state = x <EOL> def seed ( self , a = None , version = <NUM_LIT:2> ) : <EOL> """<STR_LIT>""" <EOL> self . _state = a <EOL> self . gauss_next = None <EOL> def getstate ( self ) : <EOL> """<STR_LIT>""" <EOL> return self . _state <EOL> def setstate ( self , state ) : <EOL> """<STR_LIT>""" <EOL> self . _state = state <EOL> def random ( self ) : <EOL> """<STR_LIT>""" <EOL> return window . Math . random ( ) <EOL> def getrandbits ( self , k ) : <EOL> """<STR_LIT>""" <EOL> if k <= <NUM_LIT:0> : <EOL> raise ValueError ( '<STR_LIT>' ) <EOL> if k != int ( k ) : <EOL> raise TypeError ( '<STR_LIT>' ) <EOL> numbytes = ( k + <NUM_LIT:7> ) // <NUM_LIT:8> <EOL> x = int . from_bytes ( _urandom ( numbytes , self ) , '<STR_LIT>' ) <EOL> return x >> ( numbytes * <NUM_LIT:8> - k ) </s>
