SHARE
TWEET

Untitled

a guest Mar 15th, 2019 57 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. from collections import defaultdict
  2. import numpy as np
  3.  
  4. mat = '56....1\n276....\n7.3.1..\n...124.\n..53.2.\n...4.63\n.5..4.7'
  5. d = defaultdict(list)
  6. rows = mat.split('\n')
  7. data = np.random.randint(1, 100, (len(rows), len(rows[0])))
  8. print("原始数据\n", data)
  9.  
  10. for j in range(len(rows)):
  11.     for i in range(len(rows[j])):
  12.         d[rows[j][i]].append((j, i))
  13.  
  14. for i in d['.']:
  15.     data[int(i[0])][int(i[1])] = 0
  16.  
  17. print(data)
  18.  
  19. diag_p = defaultdict(int)
  20.  
  21. for k, v in d.items():
  22.     for i in v:
  23.         diag_p[k] = data[i[0]][i[1]] ^ diag_p[k]
  24.  
  25. print(diag_p)
  26.  
  27. row_p = defaultdict(int)
  28. for rn in range(len(data)):
  29.     p = 0
  30.     for i in data[rn]:
  31.         p = p ^ i
  32.     row_p[rn] = p
  33. print(row_p)
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top