Guest User

Untitled

a guest
Nov 18th, 2017
80
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 5.35 KB | None | 0 0
  1. 2 [[0,0],[1,0]] -> [1]
  2. 3 [[0,1,0],[0,0,0],[1,1,0]] -> [2]
  3. 3 [[0,1,0],[0,0,1],[1,0,0]] -> [0,1,2]
  4. 4 [[0,1,1,1],[0,0,1,0],[0,0,0,0],[0,1,1,0]] -> [0]
  5. 4 [[0,1,1,0],[0,0,1,0],[0,0,0,1],[1,1,0,0]] -> [0,2,3]
  6. 5 [[0,1,0,0,1],[0,0,0,0,1],[1,1,0,0,0],[1,1,1,0,1],[0,0,1,0,0]] -> [3]
  7. 5 [[0,1,0,1,0],[0,0,1,1,1],[1,0,0,0,0],[0,0,1,0,1],[1,0,1,0,0]] -> [0,1,4]
  8. 5 [[0,0,0,0,0],[1,0,1,1,0],[1,0,0,0,1],[1,0,1,0,1],[1,1,0,0,0]] -> [1,3,4]
  9. 6 [[0,0,0,0,0,0],[1,0,1,1,0,0],[1,0,0,1,1,0],[1,0,0,0,1,1],[1,1,0,0,0,1],[1,1,1,0,0,0]] -> [1,2,3,4,5]
  10. 6 [[0,0,1,1,1,0],[1,0,0,1,1,1],[0,1,0,0,1,0],[0,0,1,0,0,1],[0,0,0,1,0,1],[1,0,1,0,0,0]] -> [0,1,2,3,5]
  11. 6 [[0,1,1,0,0,1],[0,0,0,1,0,1],[0,1,0,1,1,0],[1,0,0,0,1,1],[1,1,0,0,0,0],[0,0,1,0,1,0]] -> [0,1,2,3,4,5]
  12. 8 [[0,0,1,1,0,1,1,1],[1,0,1,0,1,1,0,0],[0,0,0,1,1,0,0,0],[0,1,0,0,0,1,0,0],[1,0,0,1,0,1,0,0],[0,0,1,0,0,0,1,0],[0,1,1,1,1,0,0,1],[0,1,1,1,1,1,0,0]] -> [0,1,4,6,7]
  13. 20 [[0,0,1,1,0,1,1,0,0,0,0,1,1,0,1,1,1,1,0,1],[1,0,1,1,1,0,1,1,1,1,1,0,1,1,1,1,1,1,1,1],[0,0,0,1,0,0,0,1,1,0,1,0,1,0,0,0,0,0,1,1],[0,0,0,0,1,1,1,1,1,1,1,1,0,0,1,0,0,1,1,1],[1,0,1,0,0,0,0,1,1,0,1,1,1,0,1,1,1,1,0,1],[0,1,1,0,1,0,1,1,1,1,1,0,1,1,1,0,1,1,0,1],[0,0,1,0,1,0,0,1,1,0,1,0,1,1,1,1,1,0,1,0],[1,0,0,0,0,0,0,0,1,0,1,1,1,1,0,0,1,1,1,0],[1,0,0,0,0,0,0,0,0,1,1,1,1,1,1,1,1,0,1,1],[1,0,1,0,1,0,1,1,0,0,1,0,0,0,0,1,0,1,1,1],[1,0,0,0,0,0,0,0,0,0,0,1,1,1,0,1,0,0,0,0],[0,1,1,0,0,1,1,0,0,1,0,0,1,1,1,1,1,0,1,1],[0,0,0,1,0,0,0,0,0,1,0,0,0,0,1,1,0,1,1,1],[1,0,1,1,1,0,0,0,0,1,0,0,1,0,1,1,1,1,1,1],[0,0,1,0,0,0,0,1,0,1,1,0,0,0,0,1,1,0,0,1],[0,0,1,1,0,1,0,1,0,0,0,0,0,0,0,0,0,1,1,1],[0,0,1,1,0,0,0,0,0,1,1,0,1,0,0,1,0,0,1,1],[0,0,1,0,0,0,1,0,1,0,1,1,0,0,1,0,1,0,1,1],[1,0,0,0,1,1,0,0,0,0,1,0,0,0,1,0,0,0,0,0],[0,0,0,0,0,0,1,1,0,0,1,0,0,0,0,0,0,0,1,0]] -> [0,1,3,4,5,7,8,11,15,17,18]
  14.  
  15. a"€¹o/€oḅ1M
  16.  
  17. ×Ḅ|/€|ḄBS€M
  18.  
  19. a"€¹o/€oḅ1M Main link. Argument: M (matrix)
  20.  
  21. ¹ Yield M.
  22. € For each row of M:
  23. a" Take the logical AND of each entry of that row and the corr. row of M.
  24. o/€ Reduce each resulting matrix by logical OR.
  25. o Take the logical OR of the entries of the resulting maxtrix and the
  26. corr. entries of M.
  27. ḅ1 Convert each row from base 1 to integer, i.e. sum its elements.
  28. M Get all indices of maximal sums.
  29.  
  30. ×Ḅ|/€|ḄBS€M Main link. Argument: M (matrix)
  31.  
  32. Ḅ Convert each row of M from base 2 to integer. Result: R
  33. × Multiply the entries of each column of M by the corr. integer.
  34. |/€ Reduce each row fo the resulting matrix by bitwise OR.
  35. |Ḅ Bitwise OR the results with R.
  36. BS€ Convert to binary and reduce by sum.
  37. This counts the number of set bits for each integer.
  38. M Get all indices of maximal popcounts.
  39.  
  40. @(T,N)find(sum(T*T>-T,2)>N-2)
  41.  
  42. [[0,0,0,0,0];[1,0,1,1,0];[1,0,0,0,1];[1,0,1,0,1];[1,1,0,0,0]]
  43.  
  44. a=>a.map((b,i)=>b.every((c,j)=>c|i==j|b.some((d,k)=>d&a[k][j]))&&r.push(i),r=[])&&r
  45.  
  46. Xy+HY^!Af
  47.  
  48. 4
  49. [0,1,1,0; 0,0,1,0; 0,0,0,1; 1,1,0,0]
  50.  
  51. 20
  52. [0,0,1,1,0,1,1,0,0,0,0,1,1,0,1,1,1,1,0,1; 1,0,1,1,1,0,1,1,1,1,1,0,1,1,1,1,1,1,1,1; 0,0,0,1,0,0,0,1,1,0,1,0,1,0,0,0,0,0,1,1; 0,0,0,0,1,1,1,1,1,1,1,1,0,0,1,0,0,1,1,1; 1,0,1,0,0,0,0,1,1,0,1,1,1,0,1,1,1,1,0,1; 0,1,1,0,1,0,1,1,1,1,1,0,1,1,1,0,1,1,0,1; 0,0,1,0,1,0,0,1,1,0,1,0,1,1,1,1,1,0,1,0; 1,0,0,0,0,0,0,0,1,0,1,1,1,1,0,0,1,1,1,0; 1,0,0,0,0,0,0,0,0,1,1,1,1,1,1,1,1,0,1,1; 1,0,1,0,1,0,1,1,0,0,1,0,0,0,0,1,0,1,1,1; 1,0,0,0,0,0,0,0,0,0,0,1,1,1,0,1,0,0,0,0; 0,1,1,0,0,1,1,0,0,1,0,0,1,1,1,1,1,0,1,1; 0,0,0,1,0,0,0,0,0,1,0,0,0,0,1,1,0,1,1,1; 1,0,1,1,1,0,0,0,0,1,0,0,1,0,1,1,1,1,1,1; 0,0,1,0,0,0,0,1,0,1,1,0,0,0,0,1,1,0,0,1; 0,0,1,1,0,1,0,1,0,0,0,0,0,0,0,0,0,1,1,1; 0,0,1,1,0,0,0,0,0,1,1,0,1,0,0,1,0,0,1,1; 0,0,1,0,0,0,1,0,1,0,1,1,0,0,1,0,1,0,1,1; 1,0,0,0,1,1,0,0,0,0,1,0,0,0,1,0,0,0,0,0; 0,0,0,0,0,0,1,1,0,0,1,0,0,0,0,0,0,0,1,0]
  53.  
  54. Xy % Implicitly take input: number. Push identity matrix with that size
  55. + % Implicitly take input: matrix. Add to identity matrix
  56. HY^ % Matrix square
  57. ! % Transpose
  58. A % Row vector with true entries for columns that contain all nonzero values
  59. f % Indices of nonzero values
  60.  
  61. (n,m)=>m.map((a,k)=>eval(a.map((o,i)=>o||eval(a.map((p,j)=>p&&m[j][i]).join`|`)).join`+`)>n-2&&k+1).filter(a=>a)
  62.  
  63. f=(n,m)=>m.map((a,k)=>eval(a.map((o,i)=>o||eval(a.map((p,j)=>p&&m[j][i]).join`|`)).join`+`)>n-2&&k+1).filter(a=>a)
  64.  
  65. f(20,[[0,0,1,1,0,1,1,0,0,0,0,1,1,0,1,1,1,1,0,1],
  66. [1,0,1,1,1,0,1,1,1,1,1,0,1,1,1,1,1,1,1,1],
  67. [0,0,0,1,0,0,0,1,1,0,1,0,1,0,0,0,0,0,1,1],
  68. [0,0,0,0,1,1,1,1,1,1,1,1,0,0,1,0,0,1,1,1],
  69. [1,0,1,0,0,0,0,1,1,0,1,1,1,0,1,1,1,1,0,1],
  70. [0,1,1,0,1,0,1,1,1,1,1,0,1,1,1,0,1,1,0,1],
  71. [0,0,1,0,1,0,0,1,1,0,1,0,1,1,1,1,1,0,1,0],
  72. [1,0,0,0,0,0,0,0,1,0,1,1,1,1,0,0,1,1,1,0],
  73. [1,0,0,0,0,0,0,0,0,1,1,1,1,1,1,1,1,0,1,1],
  74. [1,0,1,0,1,0,1,1,0,0,1,0,0,0,0,1,0,1,1,1],
  75. [1,0,0,0,0,0,0,0,0,0,0,1,1,1,0,1,0,0,0,0],
  76. [0,1,1,0,0,1,1,0,0,1,0,0,1,1,1,1,1,0,1,1],
  77. [0,0,0,1,0,0,0,0,0,1,0,0,0,0,1,1,0,1,1,1],
  78. [1,0,1,1,1,0,0,0,0,1,0,0,1,0,1,1,1,1,1,1],
  79. [0,0,1,0,0,0,0,1,0,1,1,0,0,0,0,1,1,0,0,1],
  80. [0,0,1,1,0,1,0,1,0,0,0,0,0,0,0,0,0,1,1,1],
  81. [0,0,1,1,0,0,0,0,0,1,1,0,1,0,0,1,0,0,1,1],
  82. [0,0,1,0,0,0,1,0,1,0,1,1,0,0,1,0,1,0,1,1],
  83. [1,0,0,0,1,1,0,0,0,0,1,0,0,0,1,0,0,0,0,0],
  84. [0,0,0,0,0,0,1,1,0,0,1,0,0,0,0,0,0,0,1,0]])
Add Comment
Please, Sign In to add comment