# Tag Info

5

Japt v2.0a0, 2 bytes Transposes, sorts each row and automatically transposes back. yn Try it Japt, 4 bytes Transpose, map, sort, transpose. ÕmÍÕ Try it

5

APL (Dyalog Extended), 5 bytes ∧⍤1⍢⍉ Try it online! Sort ∧ each row ⍤1 while transposed ⍢⍉ APL (Dyalog Unicode), 9 bytes ⊖⍳∘≢∘.≤+⌿ Try it online! +⌿ sum of each column ⍳∘≢ indices from 1 to the number of rows ∘.≤ ≤-table between these two vectors ⊖ vertically reverse the resulting matrix

5

JavaScript, 99 bytes a=>a.map((r,y)=>r.map((c,x)=>((g=i=>i--&&((i%2|x+~y&i!=4)&a[~-(y+i/3)]?.[x+i%3-1])+g(i))(9)|c)==3)) f= a=>a.map((r,y)=>r.map((c,x)=>((g=i=>i--&&((i%2|x+~y&i!=4)&a[~-(y+i/3)]?.[x+i%3-1])+g(i))(9)|c)==3)) print = (a, contain) => { let t = contain.appendChild(document....

4

Jelly, 9 bytes ZŒPZ€Ṁ€€i Try it online! Outputs 0 for falsey, non-zero for truthy -3 bytes thanks to hyper-neutrino! How it works ZŒPZ€Ṁ€€i - Main link. Takes a list of inputs I on the left and outputs O on the right Z - Transpose I ŒP - Powerset of the columns Z€ - Transpose each € - Over each column powerset: Ṁ€ - ...

4

R, 26 bytes Or R>=4.1, 19 bytes by replacing the word function with \. function(m)apply(m,2,sort) Try it online!

4

Jelly, 4 bytes ZṢ€Z Try it online! A monadic link which takes a 2d array of booleans. Z # Transpose € # For each Ṣ # Sort Z # Transpose back

3

Haskell, 41 bytes import Data.List t=transpose t.map sort.t Try it online! This is the same boring answer you've already seen in this thread. Unfortunately it's quite short. Here's a fun answer that doesn't import anything: No imports, 53 49 bytes q=foldr.zipWith e=[]:e q(:)e.q([(0:),(++)]!!)e Try it online! This answer is a little odd. Explanation ...

3

JavaScript (ES6), 55 bytes Sorting the columns. m=>m.map((r,y)=>r.map((_,x)=>m.map(r=>r[x]).sort()[y])) Try it online! JavaScript (ES6), 57 bytes Counting the number of 1's on each column. Returns a matrix of Boolean values. m=>m.map((r,y)=>r.map((_,x)=>m.some(r=>!m[n+=r[x]],n=y))) Try it online!

3

Vyxal, 6 bytes ÞTvsÞT Try it Online! There's probably something cleverer / shorter. ÞT # Transpose vs # Sort each ÞT # Transpose

3

Python 3, 34 bytes lambda a:zip(*map(sorted,zip(*a))) Try it online! -3 bytes thanks to pxeger

3

JavaScript (ES6), 109 bytes a=>a.map((r,y)=>r.map((n,x)=>[...'0124689',10].map(i=>n+=x-~y&1|i&5&&(a[y+~-(i/4)]||0)[x+i%4-1]<<1)|n>4&n<8)) Try it online!

2

BQN, 39 bytesSBCS ↕∘≠⊸{⊏⟜𝕩¨2↑⊒⊸/⊸(+⊑⊸=)⊸⊔0∾⊑˜⍟𝕨⟜⊑≠⊸|𝕨+𝕩} Try it here. ↕∘≠⊸{⊏⟜𝕩¨2↑⊒⊸/⊸(+⊑⊸=)⊸⊔0∾⊑˜⍟𝕨⟜⊑≠⊸|𝕨+𝕩} # 𝕩 is input, 𝕨 is indices 0,1,..,length-1 ↕∘≠⊸{ } # pass indices into the main function as 𝕨 ≠⊸|𝕨+𝕩 # add indices to the input mod the length ⊑˜...

2

jq, 146 bytes length as$l|def x:((.+.[-1])%$l+$l)%$l;def n:x as$x|.|index($x);. as$i|[0,[],[]]|until(n;[$i[x],.+[x],.+[\$i[x]]])|.[:n],.[n:] Try it online!

2

JavaScript (ES2020), 139 bytes x=>x.map((y,i)=>y.map((v,j)=>(v+=(g=(a,b)=>x[i+a]?.[j+b]*2|0)(0,1)+g(1,0)+g(n=-1,0)+g(0,n)+(i+j+1)%2*(g(1,1)+g(1,n)+g(n,1)+g(n,n)))>4&v<8)) Try it online! (Link uses a 142 byte version, as TIO doesn't support the ES2020 ?. operator) Explanation x=>x.map((y,i)=>y.map((v,j)=> // Map over each ...

2

MATL, 35 33 32 31 bytes t1Y6Z+G5B&*Z+G&n:w:!+o~*+E+5:7m Try it online! Or verify all test cases. How it works t % Implicit input: binary matrix. Duplicate 1Y6 % Push [0 1 0; 1 0 1; 0 1 0]. This mask defines cells that are neighbours % of the central cell, whether the central cell is a square or an octagon Z+ % 2D convolution, ...

1

Factor, 34 bytes [ flip [ natural-sort ] map flip ] Try it online! Transpose (flip), sort each row, transpose.

1

Ruby, 38 bytes ->l{l.transpose.map(&:sort).transpose} Try it online!

1

MATLAB / Octave, 13 bytes @(M)sort(M,1) Try it online! How it works Anonymous function that sorts along the 1st dimension, i.e. vertically.

1

C (clang), 92 bytes c,x,y,*p;f(*a,w,h){for(x=0;x<w;x++)for(c=y=0;y<h*2;y++)p=a+x+y%h*w,y<h?c+=*p:(*p=y-h>=h-c);} Try it online!

1

05AB1E, 7 bytes øæʒø€àQ Port of @cairdCoinheringaahing's Jelly answer, so make sure to upvote him! Outputs an empty list [] as falsey, and a non-empty list (containing one or multiple matrices of integers) as truthy. Try it online or verify all test cases. Explanation: ø # Zip/transpose the (implicit) first input-matrix, swapping rows/columns æ ...

1

Wolfram Language (Mathematica), 28 bytes Times@@Max/@(Sign[#-#2])& Try it online! Input [inputs, outputs]. Returns 0 for truthy, and nonzero (1 or -1) otherwise. Sign[#-#2] categorize indices for each i/o (-1 <, 0 =, 1 >) Max/@( ) take max for each index across i/o s Times@@ 0 present (...

1

JavaScript (ES6), 70 bytes Returns false for valid, or true for invalid. a=>a.some(b=([a,m])=>a.every((v,i)=>v-m|b[i],a.map((v,i)=>b[i]|=v>m))) Try it online!

1

Japt, 4 bytes ñÍè> Try it here

1

C++, 81 bytes int h(std::list<int>a,int i=0){int c=0;for(int x:a)c+=i<x;return i<c?h(a,i+1):i;} Similar solution to most of the other ones. Assuming that <list> is included. Non-recursive solution (85 83 bytes): int h(std::list<int>a){for(int i=0,c;;i++){c=0;for(int x:a)c+=i<x;if(i>=c)return i;}} It might be possible to put ...

1

Vyxal s, 5 bytes s₌Ṙż≥ Try it Online! A port of the 05AB1E answer. I originally had ẏ'?<∑≤ + -G, which I kinda like more. Explained s₌Ṙż≥ s # sort the input list ₌Ṙż # and push reversed(^) and range(1, len(^) + 1) ≥ # vectorise >= over ^ and input # -s sums that ẏ'?<∑≤ ẏ # The range [0, len(input)) ' # with only ...

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