Advertisement
debetimi

why being clever doesn't pay

Feb 6th, 2014
84
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.71 KB | None | 0 0
  1. import random                                                                                        
  2. from sys import maxsize
  3.  
  4. def right_timi():
  5.     counter = 0
  6.     overflow = False;
  7.     while True:
  8.         if counter == maxsize:
  9.             overflow = True
  10.         else:
  11.             overflow = False;
  12.         if move():
  13.             counter = counter - 1
  14.         else:
  15.             counter = counter + 1
  16.             if overflow:
  17.                 print 'OVERFLOW'
  18.                 return
  19.         if counter == -1:
  20.             return
  21.  
  22.  
  23. def right_mike():
  24.     if move():
  25.         return
  26.     else:
  27.         right_mike()
  28.         right_mike()
  29.  
  30. def move():
  31.    x = random.uniform(0, 1)  
  32.    return x >= 0.9
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement