# Tag Info

7

JavaScript (ES6), 55 bytes f=a=>a.some(n=>++n.length!=a[0].length)?1:f(a.flat())+1 A quite simple approach: check if all elements are the same length, increment a counter if they are and repeat with the list flattened by one level, then return the counter. -3 bytes thanks to tsh. f=a=>a.some(n=>++n.length!=a[0].length)?1:f(a.flat())+1 ...

4

Python/NumPy, 23 bytes Thx @pxeger for clarifying the legalese. from numpy import* ndim Attempt This Online! Not entirely legal Python/NumPy 22 bytes from numpy import ndim Attempt This Online! Builtin (in case you haven't noticed).

4

Vyxal, 2 bytes Ḃ+ Try it Online! Ḃ+ Ḃ # bifurcate, i.e. duplicate and reverse + # vectorized addition of two lists

4

Haskell + hgl, 22 bytes l<itr(K**l$rH lp)<pM[] Takes input as a free monad of lists (Free List a). Explanation Our strategy here is to calculate the "shape" of the array first and then derive its depth from that. We represent a shape as a list of sizes. We are going to use a recursive strategy. Our base case is a terminal element which has ... 3 R, 21 bytes function(n)n[n+1:0>0] Try it online! 3 Husk, 4 bytes fG=¹ Try it online! How? The Husk scanl command (G) applies a function to each element of a list and the result-so-far. The initial result-so-far is set to the first element. In this case, used with the eq (=) function, it checks whether each element is equal to the result-so-far. For runs of 1, this will always output 1 (truthy). Now, the ... 3 Vyxal, 4 bytes lvGg Try it Online! Why reduce by things when you can just vectorise. Explained lvGg l # overlaps of input list of size input integer. vG # maximum of each window g # minimum of that 3 Jelly, 4 bytes ṡṀ€Ṃ Try it online! Since Dennis' answer, the Ṁaximum and Ṃinimum monadic atoms have been added 3 Husk, 4 bytes ▼m▲X Try it online! Explanation ▼m▲X X each consecutive slice of length m▲ maximum of each ▼ minimum 2 05AB1E, 6 bytes ŒIù€àß Try it online or verify all test cases. Explanation: Œ # Get all sublists of the (implicit) input-list Iù # Only keep those of a size equal to the second input €à # Get the maximum of each inner list ß # Pop and push the minimum of that # (after which the result is output implicitly) 2 Factor, 34 bytes [ clump [ supremum ] map infimum ] Try it online! Explanation ! { 1 5 3 4 } 2 clump ! { { 1 5 } { 5 3 } { 3 4 } } [ supremum ] map ! { 5 5 4 } infimum ! 4 2 Julia 1.0, 48 bytes x\n=minimum(n:length(x).|>i->max(x[i-n+1:i]...)) Try it online! based on Alex A.'s answer 2 Burlesque, 7 bytes CO)>]<] Try it online! CO # Sliding window length N )>] # Map max of block <] # Min of result 2 Rust, 46 bytes |s,n|s.windows(n).map(|a|a.iter().max()).min() Try it online! Takes in a &[u32] and returns an Option<Option<&u32>>. The result will be Some(Some(&minimax)) so long as valid input is supplied. 2 Factor, 18 bytes [ "00""0"replace ] Try it online! 2 APL (Dyalog Unicode), 20 bytes {⍵+<\⍵=⌊/⍵}⊢,0~⍬≡⊢~⊃ Try it online! First we append a zero if the input is unique, then increment the first minimum (which will be the trailing zero in the unique case, as the numbers in the input are positive) ⊢~⊃ Input without all occurences of the first element. ⍬≡ Is this the empty vector? (are values in the input the ... 2 Python3, 107 bytes: f=lambda x,c=0:int in[*map(type,x)]or any(len(i)!=(c:=c or len(x[0])) for i in x)or min(1+f(i,c)for i in x) Try it online! 2 Charcoal, 43 bytes Ｗ⁼⌊ＥθＬ⁺⟦⟧κ∨⌈ＥθＬ⁺⟦⟧κω«≔⟦⟧ζＦθＦκ⊞ζλ≔ζθ⊞υω»Ｉ⊕Ｌυ Try it online! Link is to verbose version of code. Explanation: Ｗ⁼⌊ＥθＬ⁺⟦⟧κ∨⌈ＥθＬ⁺⟦⟧κω« Convert any numbers in the array to empty lists by vectorised adding them to the empty list (this leaves arrays unchanged). Compare their minimum and maximum length, unless the maximum length is 0 i.e. if the ... 1 Vyxal, 1 byte ⇧ Try It Online! 0-indexed 1 R, 29 bytes function(n)n[n|cumsum(!n)%%2] Try it online! Input as list of 0 and 1 or T/F 1 05AB1E, 10 bytes Rε''«¤ºK2£ I/O as a list of moves. This is a subset of my answer for the Expand a Rubik's Cube Commutator challenge. Try it online or verify all test cases. Explanation: R # Reverse the (implicit) input-list ε # Map over its strings: ''« # Append a "'" to each string ¤ # Push the last ... 1 Ly, 17 bytes 0&n[spG[rlr!]pp]p Try it online! This is a pretty much a direct mapping of the rules to code... After reading all the numbers onto the stack, each iteration of the loop processes the top three numbers on the stack. If the 2nd is less than the 1st, the third is appended to the end of the stack. Once the 0 delimiter is hit on the stack, the ... 1 Python 3, 50 bytes lambda l:[c for a,b,c in zip(*(iter(l),)*3)if b<a] Try it online! 1 Excel, 24 bytes =SUBSTITUTE(A1,"00","0") Inputs is a contiguous string of 0 and 1 in cell A1. Output is wherever the formula is. Straightforward use of a built-in. If the output has to be an array even though the input isn't, the formula grows to 57 bytes. =LET(a,SUBSTITUTE(A1,"00","0"),MID(a,SEQUENCE(LEN(a)),1)) If ... 1 APOL, 33 bytes j(ƒ(i ¿(!(I(∋)) ¿(≐(∈) 0 '') 1))) Explanation: j( Join list to string ƒ( List-builder for i Get input ¿( Returning if !( Not I( As number ∋ Loop item ) ) If true return ¿( Returning if ≐(∈) Loop counter is even ... 1 Pari/GP, 21 bytes a->[i|i<-q=a,i||q=!q] Try it online! 1 Husk, 6 bytes σD;0;0 Try it online! Explanation σD;0;0 σ replace all with D 2 copies of ;0 [0] ;0 [0] 1 Brainfuck, 51 bytes +[,[>+>+<<-]>>[.>+++++++[<------->-]<[,>]]<[<+>-]<] Try It Online! This program takes a string of 0's and 1's as input and prints a string of 0's and 1's as output. 1 JavaScript, 55 bytes a=>a.every(e=>e==a[0])?a.push(1):a.fill(Math.max(...a)) Modifies the array passed to it, otherwise, it's 3 bytes longer: a=>a.every(e=>e==a[0])?a.push(1)&&a:a.fill(Math.max(...a)) Try it Online! Explanation a=>a.every // Check that every element "e"... (e=>e==a[0]) // ...is equal to ... 1 Haskell + free, 8.5 bytes (17 bytes -50% bonus) In order to represent a ragged list in Haskell we use a free monad of lists. We use the free library to get these free monads. hoistFree reverse Try it online! Explanation hoistFree takes a natural transformation from some functor $F$ to another functor $G$ and makes a natural transformation from \$\...

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