30 votes

Slash the matrix

MATL, 21 bytes 3XytPJ*-X*Xj~4&1ZIunq The input is a matrix with 1 for \ and ...
Luis Mendo's user avatar
  • 104k
29 votes

Weakened Binary Walls

MATL, 4 bytes BSXB Try it at MATL Online Explanation ...
Suever's user avatar
  • 11.1k
29 votes

Is there a single straight line in the matrix?

Python 2, 49 bytes Takes as input a 2D binary matrix \$ a \$, and its size \$ n \$. lambda a,n:sorted(map(sum,a+zip(*a)))[-2:]==[1,n] Try it online! There may be ...
dingledooper's user avatar
  • 22.3k
28 votes

Which tetromino is this?

Python 3, 124 bytes ...
Lynn's user avatar
  • 68.1k
26 votes

Construct the Identity Matrix

MATL, 2 bytes Xy A translation of my Octave answer. Try it online. A 4 byte version with no built-ins (thanks to Luis Mendo): ...
a spaghetto's user avatar
  • 11.2k
20 votes

Construct the Identity Matrix

TI-BASIC, 2 bytes identity(Ans Fun fact: The shortest way to get a list {N,N} is ...
lirtosiast's user avatar
  • 21.4k
20 votes

Is it bipartite?

Wolfram Language (Mathematica), 26 25 bytes Tr[#//.x_:>#.#.Clip@x]<1& Try it online! How it works Given an adjacency matrix A, we find the fixed ...
Misha Lavrov's user avatar
  • 5,247
18 votes

Construct the Identity Matrix

Julia, 9 3 bytes eye This is just a built-in function that accepts an integer n and returns an ...
Alex A.'s user avatar
  • 24.6k
18 votes

Construct the Identity Matrix

APL, 5 bytes ∘.=⍨⍳ This is a monadic function train that accepts an integer on the right and returns the identity matrix. Try it here
Alex A.'s user avatar
  • 24.6k
18 votes

To find islands of 1 and 0 in matrix

J, 57 bytes ,&([:(0#@-.~~.@,)](*@[*[:>./((,-)#:i.3)|.!.0])^:_ i.@$)-. Try it online! This is one of those where the idea is incredibly simple (and I ...
Jonah's user avatar
  • 33k
17 votes

To find islands of 1 and 0 in matrix

APL (Dyalog Unicode), 29 28 bytesSBCS -1 thanks to @Adám {≢∪∨.∧⍨⍣≡2>+/↑|∘.-⍨⍸⍵}¨⊂,~∘⊂ Try it online! ⊂,~∘⊂ the matrix ...
ngn's user avatar
  • 15.2k
16 votes

Construct the Identity Matrix

Python 2, 42 bytes lambda n:zip(*[iter(([1]+[0]*n)*n)]*n)[:n] An anonymous function, produces output like ...
xnor's user avatar
  • 144k
16 votes

ASCII texturing

APL (Dyalog Unicode), 20 12 bytesSBCS -6 bytes through dzaima Full program. Prompts stdin for: texture as a list of strings number of rows in shape matrix number of columns in shape matrix indices ...
Adám's user avatar
  • 29.9k
16 votes

Just Enough Ones

J, 41 bytes 1#.*:=1#.2>[:>@~.@,[:+&,&.>/~i.@!<@A.=@i. Try it online! A different take on brute force, which handles up to n=6 on TIO. Since the ...
Jonah's user avatar
  • 33k
16 votes

Count my Pluses

MATL, 29 28 24 bytes z2Y6ttX*,GbZ+5Mz=z]yytvs Input is a binary matrix with 1 for '+' and <...
Luis Mendo's user avatar
  • 104k
15 votes

Is there a single straight line in the matrix?

Brachylog, 8 bytes {z|}≡ᵛ+1 Try it online! ...
Unrelated String's user avatar
14 votes

Construct the Identity Matrix

Octave, 10 4 bytes @eye Returns an anonymous function that takes a number n and returns the identity matrix.
a spaghetto's user avatar
  • 11.2k
14 votes

Decode Faux Braille

Python 3, 181 179 171 167 161 159 bytes Input by UTF-16 little-endian bytes without BOM. First decompose into columns using bit shifts, split by empty column, then hash them into a lookup table. -2 ...
Colera Su's user avatar
  • 2,421
14 votes

Mutually Attacking Queens

Python 2, 105 bytes lambda b:sum(b[i+d::d][:(8,7-i%8,i%8)[d%8%5]].find('1')*int(c)>0for i,c in enumerate(b)for d in[1,7,8,9]) Try it online! Explanation We ...
Lynn's user avatar
  • 68.1k
13 votes
Accepted

The last stage of contamination

Since this is basically talking about a cellular automaton I give you.. Golly Quicklife rule, 10 bytes 01234/234V Input the rule, paste the grid into Golly, run ...
CalculatorFeline's user avatar
13 votes

Finding Snakes in a Matrix

Python 2, 275 271 264 249 bytes Saved four bytes by replacing -1 with H and removing one slicing operation (...
Jonathan Frech's user avatar
13 votes

Is there a left-right connection?

MATLAB/Octave, 115 109 98* bytes -6 bytes thanks to Luis Mendo -7 bytes thanks to Luis Mendo ...
elementiro's user avatar
13 votes

Scribble Pad for Nerds

Vyxal, 4 bytes ×3ø^ Try it Online! 05AB1E, 3 bytes 3$Λ Try it online!
naffetS's user avatar
  • 12.2k
12 votes

Construct the Identity Matrix

R, 4 bytes diag When given a matrix, diag returns the diagonal of the matrix. However, when given an integer ...
Alex A.'s user avatar
  • 24.6k
12 votes

Decode Faux Braille

JavaScript (ES6),  148 146 143  142 bytes Saved 1 byte thanks to @ngn ...
Arnauld's user avatar
  • 189k
11 votes

The Binary Square Diagonal Sequence

Husk, 15 14 bytes zȯḋm←CtNCİ□ṁḋN Try it online! Continually prints the results as an infinite list. Explanation I wonder whether there's a better way to get ...
Martin Ender's user avatar
11 votes
Accepted

Where is that snake going?

Wolfram Language (Mathematica), 16+83=99 bytes Library import statement (16 bytes): <<Combinatorica` Actual function body (83 bytes): ...
DELETE_ME's user avatar
  • 17.2k
11 votes

Trim that distracting background off!

MATL, 5 bytes JYaZy Try it online! Or verify all test cases. Explanation ...
Luis Mendo's user avatar
  • 104k
11 votes

Calculate COVID spread

Jelly, 10 bytes ŒJạ€ŒṪ§Ṃ€Ṁ Try it online! -2 bytes thanks to Sisyphus Calculate the Manhattan differences from all 0s to all 1s, and the answer is the maximum of ...
hyper-neutrino's user avatar
  • 41.3k
11 votes

Calculate COVID spread

Wolfram Language (Mathematica), 90 78 bytes f=Length@FixedPointList[ListConvolve[CrossMatrix@1,#,{2,2},0,Times,Max]&,#]-2& Try it online! -12 bytes, ...
imas145's user avatar
  • 261

Only top scored, non community-wiki answers of a minimum length are eligible