Skip to main content
added 384 characters in body
Source Link
Dennis
  • 210.6k
  • 41
  • 370
  • 825

Jelly, 10 7 bytes

¬;/SпL

Try it online! or verify all test cases.

How it works

¬;/SпL  Main link. Input: A (list)

¬        Negate all integers in A. This replaces them with zeroes.
    п   Cumulative while loop.
   S       Condition: Compute the sum of all lists in A.
                      If the sum is an integer, it will be zero (hence falsy).
 ;/        Body:      Concatenate all lists in A.
      L  Count the number of iterations.

Update

While writing this answer, I noticed that Jelly behaves rather weirdly for ragged lists, because I calculated the depth of a list as the incremented minimum of depths of its items.

This has been addressed in the latest version, so the following code (6 bytes) would work now.

¬SSпL

This sums the rows of the array instead of concatenating them.

Jelly, 10 7 bytes

¬;/SпL

Try it online! or verify all test cases.

How it works

¬;/SпL  Main link. Input: A (list)

¬        Negate all integers in A. This replaces them with zeroes.
    п   Cumulative while loop.
   S       Condition: Compute the sum of all lists in A.
                      If the sum is an integer, it will be zero (hence falsy).
 ;/        Body:      Concatenate all lists in A.
      L  Count the number of iterations.

Jelly, 10 7 bytes

¬;/SпL

Try it online! or verify all test cases.

How it works

¬;/SпL  Main link. Input: A (list)

¬        Negate all integers in A. This replaces them with zeroes.
    п   Cumulative while loop.
   S       Condition: Compute the sum of all lists in A.
                      If the sum is an integer, it will be zero (hence falsy).
 ;/        Body:      Concatenate all lists in A.
      L  Count the number of iterations.

Update

While writing this answer, I noticed that Jelly behaves rather weirdly for ragged lists, because I calculated the depth of a list as the incremented minimum of depths of its items.

This has been addressed in the latest version, so the following code (6 bytes) would work now.

¬SSпL

This sums the rows of the array instead of concatenating them.

added 421 characters in body
Source Link
Dennis
  • 210.6k
  • 41
  • 370
  • 825

Jelly, 10 7 bytes

¬;/SпL

Try it online! or verify all test cases.

How it works

¬;/SпL  Main link. Input: A (list)

¬        Negate all integers in A. This replaces them with zeroes.
    п   Cumulative while loop.
   S       Condition: Compute the sum of all lists in A.
                      If the sum is an integer, it will be zero (hence falsy).
 ;/        Body:      Concatenate all lists in A.
      L  Count the number of iterations.

Jelly, 10 7 bytes

¬;/SпL

Try it online! or verify all test cases.

Jelly, 10 7 bytes

¬;/SпL

Try it online! or verify all test cases.

How it works

¬;/SпL  Main link. Input: A (list)

¬        Negate all integers in A. This replaces them with zeroes.
    п   Cumulative while loop.
   S       Condition: Compute the sum of all lists in A.
                      If the sum is an integer, it will be zero (hence falsy).
 ;/        Body:      Concatenate all lists in A.
      L  Count the number of iterations.
deleted 10 characters in body
Source Link
Dennis
  • 210.6k
  • 41
  • 370
  • 825

Jelly, 1010 7 bytes

¬;/Sп¬SFḢSпL

Try it online!Try it online! or verify all test casesverify all test cases.

Jelly, 10 bytes

¬;/Sп¬SFḢ

Try it online! or verify all test cases.

Jelly, 10 7 bytes

¬;/SпL

Try it online! or verify all test cases.

added 306 characters in body
Source Link
Dennis
  • 210.6k
  • 41
  • 370
  • 825
Loading
Source Link
Dennis
  • 210.6k
  • 41
  • 370
  • 825
Loading