Advertisement
qberik

Untitled

Oct 16th, 2022
1,152
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.64 KB | None | 0 0
  1. def sum_string( arr, a, b ):
  2.     n = len( arr )
  3.     for i in range( n ):
  4.         arr[a][i] |= arr[b][i]
  5.     return arr
  6.  
  7.  
  8. def yoles( arr ):
  9.  
  10.     n = len( arr )
  11.     pre_arr = None
  12.     max_count = 3
  13.     count = 0
  14.     while True:
  15.         for i in range( n ):
  16.             for j in range( n ):
  17.                 if( i != j ):
  18.                     arr = sum_string(arr, i,j )
  19.                     if arr == pre_arr:
  20.                         count += 1
  21.                     else:
  22.                         count = 0
  23.                     pre_arr = [ a[:] for a in arr ]
  24.                     if count >= max_count:
  25.                         return arr
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement