Skip to main content
added 273 characters in body
Source Link
Unmitigated
  • 2.8k
  • 1
  • 5
  • 14

JavaScript, 40 bytes

f=a=>a/a||Math.max(a.length,...a.map(f))

Try it online!

JavaScript, 43 bytes

f=a=>Math.max(~~a.length,...a.map?.(f)??[])

f=a=>Math.max(~~a.length,...a.map?.(f)??[])

console.log(f([]))
console.log(f([1,2,3]))
console.log(f([[1,2,3]]))
console.log(f([1,2,[],1]))
console.log(f([1,[1,[8,2,[1,2],5,4,9]],2,[],3]))

JavaScript, 43 bytes

f=a=>Math.max(~~a.length,...a.map?.(f)??[])

f=a=>Math.max(~~a.length,...a.map?.(f)??[])

console.log(f([]))
console.log(f([1,2,3]))
console.log(f([[1,2,3]]))
console.log(f([1,2,[],1]))
console.log(f([1,[1,[8,2,[1,2],5,4,9]],2,[],3]))

JavaScript, 40 bytes

f=a=>a/a||Math.max(a.length,...a.map(f))

Try it online!

JavaScript, 43 bytes

f=a=>Math.max(~~a.length,...a.map?.(f)??[])

f=a=>Math.max(~~a.length,...a.map?.(f)??[])

console.log(f([]))
console.log(f([1,2,3]))
console.log(f([[1,2,3]]))
console.log(f([1,2,[],1]))
console.log(f([1,[1,[8,2,[1,2],5,4,9]],2,[],3]))

Source Link
Unmitigated
  • 2.8k
  • 1
  • 5
  • 14

JavaScript, 43 bytes

f=a=>Math.max(~~a.length,...a.map?.(f)??[])

f=a=>Math.max(~~a.length,...a.map?.(f)??[])

console.log(f([]))
console.log(f([1,2,3]))
console.log(f([[1,2,3]]))
console.log(f([1,2,[],1]))
console.log(f([1,[1,[8,2,[1,2],5,4,9]],2,[],3]))