Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- 2 [[0,0],[1,0]] -> [1]
- 3 [[0,1,0],[0,0,0],[1,1,0]] -> [2]
- 3 [[0,1,0],[0,0,1],[1,0,0]] -> [0,1,2]
- 4 [[0,1,1,1],[0,0,1,0],[0,0,0,0],[0,1,1,0]] -> [0]
- 4 [[0,1,1,0],[0,0,1,0],[0,0,0,1],[1,1,0,0]] -> [0,2,3]
- 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]
- 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]
- 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]
- 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]
- 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]
- 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]
- 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]
- 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]
- a"€¹o/€oḅ1M
- ×Ḅ|/€|ḄBS€M
- a"€¹o/€oḅ1M Main link. Argument: M (matrix)
- ¹ Yield M.
- € For each row of M:
- a" Take the logical AND of each entry of that row and the corr. row of M.
- o/€ Reduce each resulting matrix by logical OR.
- o Take the logical OR of the entries of the resulting maxtrix and the
- corr. entries of M.
- ḅ1 Convert each row from base 1 to integer, i.e. sum its elements.
- M Get all indices of maximal sums.
- ×Ḅ|/€|ḄBS€M Main link. Argument: M (matrix)
- Ḅ Convert each row of M from base 2 to integer. Result: R
- × Multiply the entries of each column of M by the corr. integer.
- |/€ Reduce each row fo the resulting matrix by bitwise OR.
- |Ḅ Bitwise OR the results with R.
- BS€ Convert to binary and reduce by sum.
- This counts the number of set bits for each integer.
- M Get all indices of maximal popcounts.
- @(T,N)find(sum(T*T>-T,2)>N-2)
- [[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]]
- 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
- Xy+HY^!Af
- 4
- [0,1,1,0; 0,0,1,0; 0,0,0,1; 1,1,0,0]
- 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]
- Xy % Implicitly take input: number. Push identity matrix with that size
- + % Implicitly take input: matrix. Add to identity matrix
- HY^ % Matrix square
- ! % Transpose
- A % Row vector with true entries for columns that contain all nonzero values
- f % Indices of nonzero values
- (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)
- 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)
- f(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]])
Add Comment
Please, Sign In to add comment