boris-vlasenko

27 проверка с двумя функциями

Oct 18th, 2020
908
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. from random import randrange as rnd
  2.  
  3. def f1(data):
  4.     kol = len(data)
  5.     max_mn1 = 0
  6.     max_mn2 = 0
  7.     max_mn1_in = 0
  8.     for i in range(kol):
  9.         z_in = 1
  10.         j = data[i]
  11.         if j%2 == 0:
  12.             z_in = 2
  13.             if max_mn1<j:
  14.                 max_mn1=j
  15.                 max_mn1_in = i
  16.     if j>max_mn2 and z_in!=2 and max_mn1_in-i<9:
  17.         max_mn2=j
  18.     return max_mn1*max_mn2
  19.    
  20. def f2(data):
  21.     n = len(data)
  22.     res = 0
  23.     for i in range(n)
  24.         for ii in range(i+9,n):
  25.             p = data[i] * data[i]
  26.             if p % 6:
  27.                 if p > res:
  28.                     res = p
  29.     return res
  30.    
  31.    
  32. def f3(data):
  33.     pass
  34.  
  35.    
  36. kk = 0
  37. for i in range(100):
  38.     n = 12
  39.     data = [rnd(10) for x in range(n)]
  40.     z1 = f1(data)
  41.     z2 = f2(data)
  42.     if z1 != z2:
  43.         kk += 1
  44.         print(data,z1,z2)
  45. print(kk)
  46.  
RAW Paste Data