vmamontov

for_chat_DA_2

Dec 28th, 2021
1,152
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.58 KB | None | 0 0
  1. import random
  2.  
  3. message = 'Sorry, but there is more then 100 tries to find given value'
  4. check777 = []
  5. counter = 0
  6. max_iterations = 1000
  7.  
  8. for i in range(max_iterations):
  9.  
  10.     res = [random.randrange(10**3) for i in range(10**3)]
  11.     check = [(idx, val) for idx, val in enumerate(res) if val == 777]
  12.     if len(check) > 0:
  13.         check777 += check
  14.    
  15.     if counter == 100:
  16.         if len(check777) < 100:
  17.             print(message)
  18.         else:
  19.             print('Ok')
  20.            
  21.         print(check777)
  22.         print(len(check777))
  23.  
  24.         break
  25.    
  26.     counter += 1
Advertisement
Add Comment
Please, Sign In to add comment