Skip to main content

New answers tagged

2 votes

Diamondize a Matrix

R, 102 94 bytes \(L,N=length(L),`>`=rep)apply(t(mapply(\(j,n)c(0>n-1,j,0>N-n),L,1:N)),2,\(a)list(rev(a[0<a]))) Attempt This Online! Outputs a list of ...
int 21h Glory to Ukraine's user avatar
2 votes

Is my Matrix Arrowhead?

R, 50 49 bytes -1 byte thanks to pajonk function(x,n=1:dim(x)-1)all((!n%o%n*!diag(n))-!x) Try it online! This solution is similar to the other existing 2 answers ...
6 votes

9-16-25 2D Matrix

Brachylog, 43 bytes {hlL;Mṁ₍+ᵐ~h?∧M\+ᵐ~t?∧Mc≠{>0∧.^₂≥?∧}ᵛL∧M≜}ᵐ Try it online! Takes about 5 seconds for all 3 cases on TIO. Explanation Since Brachylog uses ...
Fatalize's user avatar
  • 38.9k
4 votes

9-16-25 2D Matrix

Nekomata + -1, 21 bytes ᵃ#*R↕v#Š:ᵐ∑ᵈv=¿:∑ᵈ§=¿ Attempt This Online! I just wanted to see how fast my golfing language can go. ...
alephalpha's user avatar
  • 48.5k
12 votes

9-16-25 2D Matrix

Picat ...
Bubbler's user avatar
  • 77k
5 votes

9-16-25 2D Matrix

Python To run the code, install the z3-solver package. It can usually solve all three cases in ~1s. ...
dingledooper's user avatar
  • 22.7k
5 votes
Accepted

9-16-25 2D Matrix

Java (Simple) backtracking approach with random candidates: ...
Tobias Grothe's user avatar
0 votes

I'm Lazy*: Top-left align my text

Perl 5 -lF, 55 bytes $i=0;map{$;[$i++].=$_ x!/ /}@F}{say map{s/.//;$&}@;for@ Try it online!
Xcali's user avatar
  • 15.3k
1 vote

Apply gravity to this matrix

K (ngn/k), 12 bytes Solution: {+{x@<x}'+x} Try it online! Explanation: ...
mkst's user avatar
  • 5,185
3 votes

I'm Lazy*: Top-left align my text

Uiua 0.11.0, 12 bytes ⍥(≡⊕⊂=@ .⍉)2 Try it out! Explanation ...
RomanPro100's user avatar
1 vote

Apply gravity to this matrix

Uiua SBCS, 8 bytes ⍜⍉≡(⊏⍏.) Try it!
chunes's user avatar
  • 24.7k
1 vote

Apply gravity to this matrix

Perl 5 -lF, 69 bytes $a=0;map$r[$a++]+=$_,@F}{say@$_ for reverse map[map$_-->0|0,@r],1..$. Try it online!
Xcali's user avatar
  • 15.3k
4 votes

Apply gravity to this matrix

Minecraft, 0 bytes This is a bit cheaty, but the question does state you can take input in "all reasonable forms" and a grid of Minecraft blocks seems reasonable enough. Input is given as a ...
LostXOR's user avatar
  • 887
2 votes

I'm Lazy*: Top-left align my text

Nibbles, 10 nibbles (5 bytes) `'.`';@|$$ Attempt This Online! Explanation It turns out that Nibbles' builtins are a very good fit for this challenge. ...
DLosc's user avatar
  • 39.7k
1 vote

Apply gravity to this matrix

Arturo, 59 bytes $=>[f:$->m->map size m\0'i->map m'r->r\[i-1]f map f&=>sort] Try it!
chunes's user avatar
  • 24.7k
0 votes

Construct the Identity Matrix

Uiua, 4 bytes ⊞=.⇡ Try it online! Read: table of = equality by ...
noodle person's user avatar
0 votes

Checkered grid with X mark

Perl 5 -n, 73 bytes $b=<>;//,say map{($'+$_)%2||2*!!$b*($b>=abs)*(abs==abs$')}@;for@;=-$_..$_ Try it online!
Xcali's user avatar
  • 15.3k
1 vote

Checkered grid with X mark

Arturo, 78 bytes $[a,b][r:..1-a,a-1map r'x->map r'y->(/\/\=x^2y*y(x*x)=<b^2b>0)?->2->abs%x+y,2] Try it!
chunes's user avatar
  • 24.7k
1 vote

Index of the row with most non-zero elements

Arturo, 31 bytes $=>[max.index map&=>[size&--0]] Try it! Explanation ...
chunes's user avatar
  • 24.7k
2 votes

Checkered grid with X mark

Pip -P, 26 25 bytes QP R*R(%$+GMCa)+2*EYb+SGb Attempt This Online! Explanation ...
DLosc's user avatar
  • 39.7k
1 vote

The Game of Cat And Mice | With Matrices

Python3, 287 bytes ...
Ajax1234's user avatar
  • 7,231

Top 50 recent answers are included