New answers tagged

1 vote

Find the box by its corners

Jelly, 20 bytes ẆZẆ$€ẎØ.p¤œịœ|ƑɗƇṪFS Try it online! Dyadic link taking \$M\$ on the left and \$L\$ on the right. ...
2 votes

Find the box by its corners

Brachylog, 20 bytes ⟨{szs}{⟨hzt⟩ⁱ²cp}⟩c+ Try it online! Takes a list [M, L] through the input variable and yields the box sum ...
0 votes

Construct the Identity Matrix

Husk, 4 bytes ´Ṫ=ḣ Try it online! ...
1 vote

Construct the Identity Matrix

K (ngn/k), 1 byte = Try it online!
  • 481
0 votes

Construct the Identity Matrix

Nibbles, 6 5 bytes (10 nibbles) .;,$.@==$_ ...
2 votes

Find the box by its corners

Charcoal, 60 bytes FLθFιFL⌊θFλ«≔⟦⟧ζF⟦ικ⟧F⟦λμ⟧⊞槧θνξ¿⬤⁺ζη⁼№ζν№ηνIΣE✂θκ⊕ι¹Σ✂νμ⊕λ Try it online! Link is to verbose version of code. Explanation: ...
  • 150k
1 vote

Construct the Identity Matrix

Pip -P, 6 bytes _=BMCa Try It Online! Just for completeness sake, here's the shortest non-builtin answer that I could find in ...
2 votes

Find the box by its corners

J, 75 72 71 70 68 66 bytes +/@,@;@((-:&(/:~)"1(;/-#:i.4)&{&>)#])&,[:g@|:&>g=.[:;@,<@(1}.<\)\. Try it online! This takes all ...
  • 30.1k
3 votes

Find the box by its corners

Python3, 222 Bytes: ...
  • 4,583
4 votes

Find the box by its corners

JavaScript (ES6), 152 bytes Expects (L)(M). ...
  • 174k
5 votes

Find the box by its corners

MATL, 53 52 bytes xZyXH:2XN!"@XJxHP:2XN!"&GJ@3$)leSwS=?2GJ@,wX{:]3$)ss Try it online! Or verfy all test cases.
  • 101k
1 vote

Make the cheapest cut

sclin, 50 bytes "tpose"Q ,"."mapf"\& fold~"Q = 2%`",_ - abs +/"map Try it here! For testing purposes: ...
2 votes

Make the cheapest cut

PARI/GP 114 bytes C(v,w)=vecsum(abs(v-w));c(M)=vecmin(concat(vector(#M-1,i,C(M[,i+1],M[,i])),vector(#M~-1,i,C(M[i+1,],M[i,]))),&L);L Input: Matrix M, output: ...
2 votes

Make the cheapest cut

05AB1E, 8 bytes ø‚€üαOWQ Outputs a pair of \$[horizontalCuts,verticalCuts]\$, where the truthy cut (1) is the minimum result (e....
3 votes

Make the cheapest cut

APL (Dyalog APL), 18 bytes ⊃∘⍋,⍥(+⌿∘|2-/⊢)∘⍉⍨ Attempt This Online! I/O Input is a numerical matrix Output is the index of the cut with the same (1-based) indexing ...
  • 4,530
0 votes

Construct the Identity Matrix

Pip, 3 bytes EYa Try It Online! Builtin.
  • 12.8k
1 vote

Make the cheapest cut

Charcoal, 36 bytes F⟦θE⌊θEθ§λκ⟧F⊖L⌊ι⊞υΣEι↔⁻§λκ§λ⊕κI⌕υ⌊υ Try it online! Link is to verbose version of code. Outputs a 0-indexed integer corresponding to the letters ...
  • 150k
3 votes

Make the cheapest cut

MATL, 13 bytes !G,wd|!s]h&X< The output indicates the cut as the letters in the challenge text, with 1, ...
  • 101k
1 vote

Construct the Identity Matrix

BQN, 4 bytes =⌜˜↕ Anonymous tacit function; returns a 2D array. Try it at BQN online! Explanation ...
  • 34.7k
3 votes

Make the cheapest cut

Jelly, 9 bytes ,ZạƝ€§NŒM A monadic Link that accepts a list of lists and yields a list of all possible minimal cuts, each of which is a pair of numbers, the (1-...
3 votes

Make the cheapest cut

J, 23 bytes (=<./)@,&(1#.2|@-/\])|: Try it online! output Output is a boolean list of "all possible horizontal cuts" followed by "all ...
  • 30.1k
4 votes

Make the cheapest cut

MATLAB / Octave, 63 46 bytes -17 bytes thanks to @Luis Mendo g=@(B)sum(abs(diff(B))') @(A)min([g(A') g(A)]) Returns an anonymous function, used like ...
4 votes

Make the cheapest cut

Excel, 321 bytes Golfed code: ...
1 vote

Calculate the inverse of a matrix

q, 3 bytes inv k, 1 byte ! Does exactly as requested. Input must be a float matrix
3 votes

Calculate the inverse of a matrix

PARI/GP 8 bytes f(A)=1/A Built-in function; particularly efficient for matrices with integer matrix elements.
0 votes

Antisymmetry of a Matrix

k, 7 bytes Similar to the APL solution. Compare (x~) original matrix against negated transpose (-+x} {x~-+x}
0 votes

Antisymmetry of a Matrix

J-uby, 28 bytes Port of Razetime's Ruby answer. :=~&(:transpose|:*&(:*&:-@)) Attempt This Online! Explanation ...
  • 8,816
0 votes

Zigzagify a Matrix

05AB1E, 11 bytes ΣN²‰ÐOŠO<è‚ Inputs as flattened_list, width, height (even though I ignore the ...
1 vote

Reconstruct a zigzagified matrix

K (ngn/k), 36 bytes {y#x@<,/((#c)#(|:;::))@'c:.=+/!y:|y} Try it online! Basically the same as Zagify a matrix but with a grade.
  • 481
3 votes

Zigzagify a Matrix

K (ngn/k), 50 41 bytes -9 Can use odometer directly {(,/x)@,/((#c)#(|:;::))@'c:.=+/!#'(x;*x)} Try it online!
  • 481

Top 50 recent answers are included