Hot answers tagged

59 votes

Make it explode!

Operation Flashpoint scripting language, 182 bytes ...
Steadybox's user avatar
  • 16.5k
42 votes

Where's the 0xBEEF?

vim, 126 80 77 76 /\v1011\_.{9}(1110\_.{9}){2}1111<cr>:exe'norm Go'.join(getpos('.'))<cr>xxdawhPXXd{ Expects input in the form ...
Doorknob's user avatar
  • 71.4k
41 votes

Remove surrounding zeroes of a 2d array

Wolfram Language (Mathematica), 42 bytes #&@@CellularAutomaton[{,{},0{,}},{#,0},0]& Try it online! Cellular automata are indeed the answer to life, the ...
JungHwan Min's user avatar
  • 13.8k
31 votes
Accepted

Zigzagify a Matrix

J, 31 30 14 12 11 bytes [:;<@|.`</. Ych. Too big. Takes a matrix as input. Explanation J has an advantage here. There's a command called oblique (...
Gareth's user avatar
  • 11.3k
30 votes
Accepted

Where's the 0xBEEF?

Jelly, 20 17 16 bytes ṡ€4ḄZw€“¿ÇÇБĖUṀ Input is in form of a Boolean matrix, output is the 1-based index pair (Y, X). Try it online! or verify all test cases. ...
Dennis's user avatar
  • 209k
30 votes

Dig a border trench

Wolfram Language (Mathematica), 15 bytes 2#-#~Erosion~1& Try it online! Or (39 bytes): ...
lirtosiast's user avatar
  • 21.4k
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

Determinant of an Integer Matrix

Jelly, 15 bytes LŒ!ðŒcIṠ;ị"Pð€S Try it online! How it works ...
Leaky Nun's user avatar
  • 49.5k
28 votes

I transpose the source code, you transpose the input!

Python 3 + numpy, 45 bytes lambda\ a:a ma= """ b. " dT" " a " \ """ Try it online! Thanks to @EriktheOutgolfer pointing out a bug of the previous version ...
Joel's user avatar
  • 1,751
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
24 votes

Calculate the inverse of a matrix

Octave, 57 bytes A=input('');V=A'/trace(A*A');for i=1:1e4V=2*V-V*A*V;end V Try it online! This is not particularly well golfed, but I wanted to advertise an ...
Sisyphus's user avatar
  • 14.4k
22 votes

Where's the 0xBEEF?

JavaScript (ES6), 63 60 56 bytes s=>[(i=s.search(/1011.{9}(1110.{9}){2}1111/))%13,i/13|0] Takes input as a 155-character space-delimited string of 12 12-digit ...
Neil's user avatar
  • 163k
22 votes

First spiral, then diagonal

R, 43 34 bytes function(n)(8*n^3-3*n^2+4*n+3)%/%6 Try it online! The OEIS page lists the following formula for a(n): ...
Giuseppe's user avatar
  • 27.9k
21 votes
Accepted

Matrix in "slash" order

Jelly, 6 5 bytes pSÞỤs Try it online! How it works ...
Dennis's user avatar
  • 209k
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
Accepted

Diamondize a Matrix

J, 6 bytes <@|./. This is an unnamed a monadic verb which takes a matrix and returns a list of antidiagonals: ...
Martin Ender's user avatar
20 votes

Orthodiagonal steps

Octave, 24 bytes dec2base([0:3,5:8],3)-49 Try it online! I haven't seen this approach yet. Creates a list of integers ...
Stewie Griffin's user avatar
20 votes

Is the matrix centrosymmetric... and so is the code?

JavaScript (ES6), size 12 11 9 All versions return false for centrosymmetric or true for non-centrosymmetric. 1-dimensional array + length, size 9 (89 bytes) Takes input in currying syntax ...
Arnauld's user avatar
  • 186k
19 votes

Transposes and Diagonals

Javascript, score 20 14, (258 176 non-newline characters) ...
Endenite's user avatar
  • 4,051
19 votes

Matrix with 1 to L(n), in all n columns

R, 40 38 bytes function(l)outer(m<-1:max(l),l,"<=")*m Try it online! Explanation: outer applies its third argument (...
Giuseppe's user avatar
  • 27.9k
19 votes

Friar simulator

Grime, 20 bytes n`.\1./\3.\4/.\2.voO Try it online! A very literal implementation of the spec: n` make Grime count the ...
Martin Ender's user avatar
19 votes
Accepted

Rebuild a rectangular array from a corner

Canvas, 1 byte Try it here! Outputs as a multiline string
dzaima's user avatar
  • 20.2k
19 votes

Find the inverse of a 3 by 3 matrix

MATL, 54 bytes th3LZ)t,3:q&XdpswP]w-lw/GtY*tXdsGXdsUw-IXy*2/+GtXds*-* Try it online! Just to keep it interesting, doesn't use the inbuilt matrix division or ...
Sundar R's user avatar
  • 6,582
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

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

Is the matrix centrosymmetric... and so is the code?

Jelly, score 2 ⁼Ṛ Ṛ⁼ Try it online! Takes input as a flattened square matrix (vector of size \$n^2\$).
Erik the Outgolfer's user avatar
18 votes

Make a Rectangle from a Triangle

Python 2, 59 bytes n=input() c=~n%2 while c<n:print`n%10`*n+`c%10`*c;n-=1;c+=1 Try it online! Prints like: ...
xnor's user avatar
  • 144k
18 votes

Output a Latin Square

Python 2, 37 bytes Outputs a flattened \$ n \times n \$ latin square. lambda n:((range(n)*-~n)[1:]*n)[::~n] Try it online!
dingledooper's user avatar
  • 22.2k
17 votes

Recursive Z-matrix

Jelly, 5 bytes 4ṗ>2Ġ Try it online! Neil saved a byte. Thanks! ...
Lynn's user avatar
  • 67.9k
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

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