[Question]
  [
Grouping takes a list and splits it into new lists of equal adjacent elements. For example
```
[1,1,2,1,1] -> [[1,1],[2],[1,1]]
```
If you then take the length of these groups you get a new list of integers
```
[1,1,2,1,1] -> [2,1,2]
```
Your task is to write a program that takes a list of positive integers and find the number of times you can group and length it before the resulting list has a single element. For example the list `[1,2,3,3,2,1]` can be regrouped 4 times
```
[1,2,3,3,2,1]
[1,1,2,1,1]
[2,1,2]
[1,1,1]
[3]
```
This is [code-golf](/questions/tagged/code-golf "show questions tagged 'code-golf'") so answers will be scored in bytes with fewer bytes being better.
# Test cases
```
[1,2,3,3,2,1] -> 4
[1,2,3,4,5,6,7] -> 2
[1,1,1,1,1,1] -> 1
[2] -> 0
[1,2,4] -> 2
[1,2,2,1,1,2] -> 4
[1,2,2,1,1,2,1,2,2] -> 5
[1] -> 0
```
  
[Answer]
## Haskell, 49 bytes
```
import Data.List
f[_]=0
f c=1+f(length<$>group c)
```
[Try it online!](https://tio.run/##y0gszk7Nyfn/PzO3IL@oRMElsSRRzyezuIQrLTo@1taAK00h2dZQO00jJzUvvSTDRsUuvSi/tEAhWfN/bmJmnoKtQm5igW@8gkZBUWZeiV6apkI0l4JCtKGOkY4xEBrpGMbqIARMdEx1zHTMYUJwCBEwQig1QTCNwEqMMATA2Cg29j8A "Haskell – Try It Online")
[Answer]
## [CJam](https://sourceforge.net/p/cjam), 18 bytes
```
q~_,{_e`0f=}*]:,1#
```
[Try it online!](https://tio.run/##S85KzP3/v7AuXqc6PjXBIM22VivWSsdQ@f//aEMFIyA0VDAEk0B2LAA "CJam – Try It Online")
[Answer]
# [Brachylog](https://github.com/JCumin/Brachylog), 12 bytes
```
;.{ḅlᵐ}ⁱ⁾l1∧
```
[Try it online!](https://tio.run/##SypKTM6ozMlPN/r/31qv@uGO1pyHWyfUPmrc@KhxX47ho47l//9HG@oYAaGhjiGYBLJj/0cBAA "Brachylog – Try It Online")
### Explanation
```
;.{   }ⁱ⁾        Iterate Output times the following predicate on the input:
   ḅ               Group consecutive equal elements together
    lᵐ             Map length
         l1∧     The result of this iteration must have length 1
```
[Answer]
# [Japt](https://github.com/ETHproductions/japt), 12 bytes
```
ÊÉ©1+ßUò¦ ml
```
[Test it online!](https://ethproductions.github.io/japt/?v=1.4.5&code=ysmpMSvfVfKmIG1s&input=WzEsMiwzLDQsNSw2LDdd)
### Explanation
```
 Ê É © 1+ßUò¦  ml
Ul -1&&1+ßUò!= ml    Ungolfed
                     Implicit: U = input array
Ul -1                Take U.length - 1.
     &&              If this is non-zero:
          Uò!=         Split U between non-equal elements.
               ml      Take the length of each run of equal elements.
         ß             Run the entire program again on the resulting array.
       1+              Add one to the return value.
```
Recursion is a really non-conventional approach for Japt, but it seems to be 4 bytes shorter than the next alternative...
[Answer]
# [K (oK)](https://github.com/JohnEarnest/ok), ~~20~~ 19 bytes
**Solution:**
```
#2_{#:'(&~~':x)_x}\
```
[Try it online!](https://tio.run/##y9bNz/7/X9kovlrZSl1Dra5O3apCM76iNsZQwUjBGAiNFAz//wcA "K (oK) – Try It Online")
**Examples:**
```
#2_{#:'(&~~':x)_x}\1 2 3 3 2 1
4
#2_{#:'(&~~':x)_x}\1 2 3 4 5 6 7
2
#2_{#:'(&~~':x)_x}\1 1 1 1 1 1
1
#2_{#:'(&~~':x)_x}\1#2
0
#2_{#:'(&~~':x)_x}\1 2 4
2
```
**Explanation:**
This one is pretty simple, am wondering if there is an even better approach though... Find the indices where the input differs, split at those indices and then count the length of each sub-list. Iterate until results converge to 1.
```
#2_{#:'(&~~':x)_x}\ / the solution
   {             }\ / scan over lambda until results converge
                x   / implicit input
               _    / cut at indices
       (      )     / do this together
         ~~':x      / differ... not (~) match (~) each-previous (':) x)
        &           / indices where true
    #:'             / count (#:) each (')
 2_                 / drop first two results
#                   / count result
```
**Notes:**
The following **14 byte** solution works for all **except** a single-item list:
```
#1_(-':&~~':)\
```
[Try it online!](https://tio.run/##y9bNz/7/X9kwXkNX3Uqtrk7dSjPGUMFIwRgIjRQM//8HAA "K (oK) – Try It Online")
[Answer]
# [J](http://jsoftware.com/), 25 23 bytes
1 byte saved thanks to streetster
1 byte saved thanks to FrownyFrog
```
2#@}.#;.1@(0,2=/\])^:a:
```
[Try it online!](https://tio.run/##y/qvpKeepmBrpaCuoKNgoGAFxLp6Cs5BPm7/jZQdavWUrfUMHTQMdIxs9WNiNeOsEq3@a3IpcKUmZ@QrpCkYKhgpGAOhkYIhqpCJgqmCmYI5QhAOYUJGyBpMkDlGYIVGWIQgbLjEfwA "J – Try It Online")
Initial solution:
```
_2+[:#(#;.1~1,2~:/\])^:a:
```
[Try it online!](https://tio.run/##y/qvpKeepmBrpaCuoKNgoGAFxLp6Cs5BPm7/4420o62UNZSt9QzrDHWM6qz0Y2I146wSrf5rcilwpSZn5CukKRgqGCkYA6GRgiGqkImCqYKZgjlCEA5hQkbIGkyQOUZghUZYhCBsuMR/AA "J – Try It Online")
## Explanation
```
      (               )^:a: - repeat until result stops changing, store each iteration
        ;.1~                - cut the input (args swapped)              
            1,2~:/\]      - where the items are no longer the same
       #                    - and take the length of the sublists
 2+[:#                      - finally subtract 2 from the number of steps
```
[Answer]
# [Husk](https://github.com/barbuz/Husk), 8 bytes
-1 byte thanks to @Zgarb!
```
←Vε¡(mLg
```
[Try it online!](https://tio.run/##yygtzv7//1HbhLBzWw8t1Mj1Sf///3@0oY4REBrqGIJJIDsWAA "Husk – Try It Online")
### Explanation
```
←Vε¡(mLg)  -- example input: [1,2,3,3,2,1]
   ¡(   )  -- repeatedly apply the function & collect results
    (  g)  -- | group: [[1],[2],[3,3],[2],[1]]
    (mL )  -- | map length: [1,1,2,1,1]
           -- : [[1,2,3,3,2,1],[1,1,2,1,1],[2,1,2],[1,1,1],[3],[1],[1],...
 V         -- index where
  ε        -- | length is <= 1: [0,0,0,0,1,1...
           -- : 5
←          -- decrement: 4
```
[Answer]
## JavaScript (ES6), ~~67~~ ~~65~~ 63 bytes
```
f=a=>a[1]?1+f(q=j=i=[],a.map(x=>x^a[++i]?j=!q.push(++j):++j)):0
```
Oddly enough, JavaScript and Japt seem to have the same shortest algorithm for once...
[Answer]
# [Stax](https://github.com/tomtheisen/stax), 9 [bytes](https://github.com/tomtheisen/stax/blob/master/docs/packed.md#packed-stax)
```
ÆÑfá╒]`*Ä
```
[Run and debug it online](https://staxlang.xyz/#c=%C3%86%C3%91f%C3%A1%E2%95%92%5D%60*%C3%84&i=%5B1%2C2%2C3%2C3%2C2%2C1%5D%0A%5B1%2C2%2C3%2C4%2C5%2C6%2C7%5D%0A%5B1%2C1%2C1%2C1%2C1%2C1%5D%0A%5B2%5D%0A%5B1%2C2%2C4%5D%0A%5B1%2C2%2C2%2C1%2C1%2C2%5D%0A%5B1%2C2%2C2%2C1%2C1%2C2%2C1%2C2%2C2%5D%0A%5B1%5D&a=1&m=2)
The ascii representation of the same program is this.
```
{D}{|RMHgf%
```
This uses a stax feature called a [generator](https://github.com/tomtheisen/stax/blob/master/docs/generators.md#generators) that produces value according to transformation and filter blocks.
```
{ }            the filter for the generator
 D             tail of array; this is truthy for length >= 2
   {    gf     generator block - termination condition is when the filter fails
    |R         run-length encode into pairs [element, count]
      M        transpose matrix
       H       last element
          %    length of final generated array
```
[Answer]
# [C (gcc)](https://gcc.gnu.org/), ~~108~~ 103 bytes
* Saved five bytes thanks to [ceilingcat](https://codegolf.stackexchange.com/users/52904/ceilingcat).
```
j,k,n;f(A,l)int*A;{for(j=k=n=0;j<l;j++)n=A[j]-A[k]?A[k++]=n,A[k]=A[j],1:n+1;A=l>1?-~f(A,k,A[k++]=n):0;}
```
[Try it online!](https://tio.run/##jY9RC4IwFIWf62cEwdaO4FYpuZbsd4gPYRhOWyG92frrNqV6zDjcC@fycQ63CM5F0fcGNawsiUZDK3tfadmV15YYVSurQmn2jTSMUat0ZvJAZ3We@sVYriwGN97BE8u41Ko58DR4Dmk1PhhNQun6y7GyhHbz2a31NSVZLE@PBUpCvMty2nEIrL0EuENEqZwgN9giQuwQ/2a/mkgVDnyqdeOwnmLE2Cb@@OFNjuP53cC7/gU "C (gcc) – Try It Online")
# Explanation (108 bytes version)
```
j,k,n;                // array pos, group pos, group val
f(A,l)int*A;{         // function takes array and length
 for(j=k=n=0;j<l;j++) // initialize, loop through array
  if(n++,             // increase n (*), check if group ended
  A[j]-A[k])          // group ended
   A[k++]=--n,        // advance group pos, decrease n, counteracting (*)
   A[k]=A[j],         // store new group type
   n=1;               // group is at least one long
 A=l>1?               // check if array length is larger than one
  -~f(A,k,A[k++]=n)   // fix last group length, enter recursion
  :0;}                // array length is less than two, return zero
```
[Try it online!](https://tio.run/##jVLtTp1AEP1dnmJj0oSVIQpaTUtpw3Pc8GMDA3eBzpJl0eotffXbQdCgpr1lQwLJ@ZhzZouwLorjsYEWKBFvnosLoaxVD6I3A4jamrHfft6pzqv8DDqpyZ1nyWFLrEYqnDYknGpxWHUUlaJDqt3eE5WxfpO2KaWXSfO1S5ogkDNRk3ZadfoRQXTG9MLt2a3eLxKeELryKQjg7aSaCotqQEHCP5cgij0WLYPXYZFKLJmd7Zo8zHZtLl@xX4MY1QZBnoYhwbaM8k5RgdsmSnx2ZUczkkOrODfV8xCrUp7OprC1G5yxzMH7Vcs99DijKY2S90tYMJpbdFyfGpwwhFwO1Z7I0u5b9P095yX@0vzS@qzRKVuj5VYVzTLsGv6et9jCGprkukH9k8FsttgvCsAdcUZhsRjtwPtl/pfLZPrr1dkY4zAstu7eACu40ZJ4RGuOP5QmXx68D73lq1T5Zx/LX2dQ@T7/7XJ5iCCGKz4xRBPcSJmcQF7DJ7iB2wlu/419OSdU4wmiU67XE1ydwsRPbvF/ZFiRTy/jP8/46fgH "C (gcc) – Try It Online")
[Answer]
# [APL (Dyalog Unicode)](https://www.dyalog.com/), ~~33~~ 24 bytes
Saved 9 bytes thanks to @[Adám](https://codegolf.stackexchange.com/users/43319/ad%c3%a1m)!
```
{1=≢⍵:0⋄1+∇2-/⍸2≠/0,⍵,0}
```
[Try it online!](https://tio.run/##SyzI0U2pTMzJT///v9rQ9lHnoke9W60MHnW3GGo/6mg30tV/1LvD6FHnAn0DHaCMjkHt/7RHbRMe9fY96mo@tN74UdvER31Tg4OcgWSIh2fw/zQFQzA0AkJDrjQwyxgIETwTEA1lG0HVgtkA "APL (Dyalog Unicode) – Try It Online")
```
{
 1=≢⍵           ⍝If the length (≢) of the input (⍵) is 1
  :0            ⍝return 0, as we can't go further
⋄1+             ⍝Otherwise, add 1 to the result of the next call:
  ∇2-/⍸2≠/0,⍵,0 ⍝Next step
         0,⍵,0  ⍝ Put 0s on both sides (1 1 1 2 2 1 -> 0 1 1 1 2 2 1 0)
      2≠/       ⍝Pairwise reduce with ≠
                ⍝0 1 1 1 2 2 1 0 -> 1 0 0 1 0 1 1
                ⍝There is now a 1 wherever a run starts
      ⍸          ⍝Indices of 1s (indices where runs start)
                ⍝1 0 0 1 0 1 1 -> 1 4 6 7
   2-/          ⍝Pairwise reduce with subtraction (length of each run)
                ⍝1 4 6 7 -> 3 2 1
 ∇              ⍝Call itself with new list
}
```
```
[Answer]
# [CJam](https://sourceforge.net/p/cjam), 19 bytes
```
q~{_);}{_e`0f=}w],(
```
[Try it online!](https://tio.run/##S85KzP3/v7CuOl7TurY6PjXBIM22tjxWR@P/fwA "CJam – Try It Online")
[Answer]
# [CJam](https://sourceforge.net/p/cjam), 20 bytes
```
l~{__,(}{e`z0=}w;;],
```
[Try it online!](https://tio.run/##S85KzP1f/T@nrjo@Xkejtjo1ocrAtrbc2jpW53@BYW36/2hDBSMFYyA0UjCM5YLyTBRMFcwUzMF8OATyjKAqTKC0EVjGCJUHxkaxAA "CJam – Try It Online")
[Answer]
# [Perl 5](https://www.perl.org/), ~~53~~ ~~50~~ ~~49~~ 45 bytes
Includes `+3` for `-p`
Give the list of numbers as one line on STDIN
```
#!/usr/bin/perl -p
s%%$\+=1<s:\d+:$.++x($'-$&and$.=1):eg%eg}{
```
[Try it online!](https://tio.run/##K0gtyjH9/79YVVUlRtvW0KbYKiZF20pFT1u7QkNFXVdFLTEvRUXP1lDTKjVdNTW9tvr/f0MFIwVjIDRSMPyXX1CSmZ9X/F@3AAA "Perl 5 – Try It Online")
[Answer]
# [Jelly](https://github.com/DennisMitchell/jelly), 10 bytes
```
ŒgL€$ḊÐ¿L’
```
[Try it online!](https://tio.run/##y0rNyan8///opHSfR01rVB7u6Do84dB@n0cNM/8fbgeKRP7/H82lEG2oY6RjDIRGOoaxOnC@iY6pjpmOOVQEDsF8I7g6EzjLCCxvhM4HY6gokIwFAA "Jelly – Try It Online")
[Answer]
# [Python 2](https://docs.python.org/2/), 84 bytes
```
f=lambda a:len(a)>1and-~f(eval(''.join('1'+',+'[x==y]for x,y in zip(a,a[1:]))+'1,'))
```
**[Try it online!](https://tio.run/##VY7BCoMwEETP7VfkthtcC0ltC4L@iOSwRUMtNooNRXvor9sYpFCGZXk7A7PD7G@908tii44f15oF513jkGWp2NXpx2Lz4g4BDve@dQgKEqAEqqkoZmP7UUw0i9aJdzsgE1cqN1ImoAikXFbfN0@/BrBSpOkYpEkZ2iijE53pEvmnQHpLZNvW0dH/FEcbme93w9g6H7tIQFoChUqPFtdLeOQL "Python 2 – Try It Online")**
### How?
`f` is a recursive function which, if its input, `a`, has length 2 or more (`len(a)>1`) returns `1+f(x)`\* where `x` is the group lengths of `a`; while if its input is length 1 or 0 returns `False` (equal to 0 in Python) - this is because the right hand side of the `and` does not get evaluated when the left is falsey.
\* `-~f(x)` is `-(-1 - f(x))` but can abut the `and` unlike `1+f(x)` or `f(x)+1`)
The group lengths are calculated by creating code which is then evaluated with `eval(...)`. The code created is something like `1,1,1+1+1,1,1+1,1,` which evaluates to a tuple like `(1,1,3,1,2,1)`.
The code is created by zipping through `a` and `a` without its head (`...for x, y in zip(a,a[1:])` making `x` and `y` each of the adjacent pairs in `a`. If the pair are equal `x==y` evaluates to `True` (1) otherwise `False` (0) - this result is used to index into the string `,+` yielding `+` and `,` respectively and each resulting character is preceded by a `1` (`'1'+...`) - the whole thing then has a final, trailing `1,` appended. For example if `a` were `[5,5,2,9,9,9]` then the `x,y` pairs would be `(5,5)(5,2)(2,9)(9,9)(9,9)` making the equalities `10011` then the characters would be `+,,++`, which with the preceding `1`s becomes `1+1,1,1+1+` and the final trailing `1,` making `1+1,1,1+1+1,` which evaluates to `(2,1,3)` as required.
Note that the trailing `,` ensures that an input with a single group is evaluated as a tuple rather than an integer (i.e. `[3,3]` -> `1+1,` -> `(2)` rather than `[3,3]` -> `1+1` -> `2`)
[Answer]
# [05AB1E](https://github.com/Adriandmen/05AB1E), 9 bytes
```
[Dg#γ€g]N
```
[Try it online!](https://tio.run/##MzBNTDJM/f8/2iVd@dzmR01r0mP9gDxDHSMgNNQxBJNAdiwA "05AB1E – Try It Online")
**Explanation**
```
[Dg#   ]     # loop until the length of the current value is 1
    γ        # split into groups of consecutive equal elements
     €g      # get length of each
        N    # push the iteration variable N
```
[Answer]
# [Wolfram Language (Mathematica)](https://www.wolfram.com/wolframscript/), 32 bytes
Saved 2 bytes thanks to Martin Ender. Using CP-1252 encoding, where `±` is one byte.
```
±{_}=0;±x_:=1+±(Length/@Split@x)
```
[Try it online!](https://tio.run/##y00syUjNTSzJTE78///Qxur4WlsD60MbK@KtbA21D23U8EnNSy/J0HcILsjJLHGo0PwfUJSZVxKtrKOgpKBrp6Cko3Boo3KsgpqCvoNCdbWhjpGOMRAa6RjW6ihAuSY6pjpmOuYQATgEcY1gikxgDCOwpBEaF4whgrW1/wE "Wolfram Language (Mathematica) – Try It Online")
[Answer]
# [Ruby](https://www.ruby-lang.org/), ~~54 56 55~~ 54 bytes
```
g=->l,d=0{l[1]?g[l.chunk(&:i).map{|i,j|j.size},d+1]:d}
```
[Try it online!](https://tio.run/##VY7LCsIwEEX3/YrBglgcg4mtQqH6ISGImtIm1ge2WWiab6@xalEuszl35jA3s793XZHN1hXKbG4rTsWm4BU5lOZ8nIxTFZHT7mpbhbrVpFaP3KGcUpFK13HOKTJc@DCkAiEWGHxZjAkuceUp@9AhntGe@Qbmw038s8teRh/2Z/2wfl5N8m56iyD57lCCvID/FXQbAFxNU8MotIo0l21NKm3qBtjKwWwNoS24Eg4modUuGgX5WXZP "Ruby – Try It Online")
[Answer]
# SmileBASIC, ~~110~~ 108 bytes
```
DEF R L,J
K=LEN(L)FOR I=1TO K
N=POP(L)IF O-N THEN UNSHIFT L,0
INC L[0]O=N
NEXT
IF I<3THEN?J ELSE R L,J+1
END
```
Call function as `R list,0`; output is printed to the console.
[Answer]
# [Jelly](https://github.com/DennisMitchell/jelly), 6 bytes
```
ŒɠƬṖṖL
```
[Try it online!](https://tio.run/##y0rNyan8///opJMLjq15uHMaEPn8P9z@qGlN5P//0VwK0YY6RjrGQGikYxirA@eb6JjqmOmYQ0XgEMw3gqszgbOMwPJG6HwwhooCyVgA "Jelly – Try It Online")
I assume that `Œɠ` did not exist when Dennis wrote his solution, and it wouldn't surprise me if this challenge had even inspired him to add it, but it's worth showing that this solution is possible now.
[Answer]
# [Python 2](https://docs.python.org/2/), 85 bytes
```
from itertools import*
f=lambda a:~-len(a)and-~f([len(list(v))for k,v in groupby(a)])
```
[Try it online!](https://tio.run/##bY5BCoMwEEX3nmLqypQINdUWCi56juIiomlDYxKSVHDj1dNYpbQin1nMvD9/Rg/uoSTxnhnVAXetcUoJC7zTyrh9xEpBu7qhQC9jKlqZUERlk44suU2d4NYlPUJMGXjiHriEu1EvXQ/BWCFPrQ2JENwZJvgYRHBWIShLyKM1zHGBT/g8Y/KHv5ph9gPJPDqs4vKtGDKdDyLbLyzwU4uliLTh0kF8FQJca50FPS01u9i/AQ "Python 2 – Try It Online")
[Answer]
# [R](https://www.r-project.org/), ~~51~~ 45 bytes
```
f=function(a)"if"(sum(a|1)>1,f(rle(a)$l)+1,0)
```
[Try it online!](https://tio.run/##K/r/P802rTQvuSQzP08jUVMpM01Jo7g0VyOxxlDTzlAnTaMoJxUorpKjqW2oY6D5P00jWcNQx0jHGAiNdAw1Nf8DAA "R – Try It Online")
Recursively take the length of the run length encoding and increment the counter.
[Answer]
# [Retina 0.8.2](https://github.com/m-ender/retina/wiki/The-Language/a950ad7d925ec9316e3e2fb2cf5d49fd15d23e3d), 31 bytes
```
,.*
$&_
}`(\b\d+)(,\1)*\b
$#2
_
```
[Try it online!](https://tio.run/##K0otycxL/K@qoeGe8F9HT4tLRS2eqzZBIyYpJkVbU0MnxlBTKyaJS0XZiCv@//9oQx0jHWMgNNIxjOWC8kx0THXMdMzBfDgE8oygKkygtBFYxgiVB8ZGsQA "Retina 0.8.2 – Try It Online") Link includes test cases. Explanation:
```
,.*
$&_
```
If there is a comma, we're going to make another iteration, so append a count character.
```
}`(\b\d+)(,\1)*\b
$#2
```
Replace each run with its decremented length. The above stages repeat until there are no commas left.
```
_
```
Count the number of iterations.
[Answer]
# [Perl 6](https://perl6.org), 52 bytes
```
{+($_,*.comb(/(\d+)[" "$0»]*/).map(+*.words)...^1)}
```
[Test it](https://tio.run/##XZDRboIwFIbv@xQnhiwtdNV2yBIJxofYnXOGQTVkIA0tbsb4ZLvbi7FSGcblT5Pm@8/523OUbMqoa7WEY8SyGKHqBA9ZnUtIunOAvS31WVZX73iKX/OArCcw8WY/3xt/SliVKhz47LNuck0YY2@cXDrbvzJSG0gAI4A1p4I@WQnKN5AsIaQ3GtI5jeiz42Lgoxzljgp3n42d4V2H6LOtxL/8gbpz9eZX7y6N/5k2jsSo38SL/X6MVJkeIHCzxGhXN8NYj0vwtoBh8SFPeFUcVGsIhcUxLVuJPfmlZGZkToDA2T5QaOiXeSscKyiwfaENunS/ "Perl 6 – Try It Online")
## Expanded:
```
{  # bare block lambda with implicit parameter ｢$_｣
  + (              # turn the following into a Numeric (get the count)
      $_,          # seed the sequence with the input
      *.comb(      # turn into a string, and grab things that match:
        /          # regex
          ( \d+ )  # a run of digits (number)
          [
            " "    # a space
                   # (gets inserted between elements of list when stringified)
            $0     # another instance of that number
            »      # make sure it isn't in the middle of a number
          ]*       # get as many as possible
        /
      ).map(
        +*.words  # turn each into a count of numbers
      )
      ...^        # keep doing that until (and throw away last value)
      1           # it gives a value that smart-matches with 1
                  # (single element list)
  )
}
```
[Answer]
# [Brain-Flak](https://github.com/DJMcMayhem/Brain-Flak), 78 bytes
```
({}<>)<>({()<(<>{}<(())><>){({}[({})]<>){((<{}>))}{}((){})<>}<>{}({}<>)<>>}{})
```
[Try it online!](https://tio.run/##NUw7CoBQDLvKG5vBoc6lFxGH5yCI4uBaevYaH0hJyI9uTz/uab/6WSWR5jCXEJiY04oAzjDYLQTWYcQiHchIDpia5zf/HzgLVGmbedp0MPUL "Brain-Flak – Try It Online")
[Answer]
# [Pyth](https://pyth.readthedocs.io), 9 bytes
```
ltt.uhMr8
```
**[Test suite!](https://pyth.herokuapp.com/?code=ltt.uhMr8&input=%5B1%5D&test_suite=1&test_suite_input=%5B1%2C2%2C3%2C3%2C2%2C1%5D%0A%5B1%2C2%2C3%2C4%2C5%2C6%2C7%5D%0A%5B1%2C1%2C1%2C1%2C1%2C1%5D%0A%5B2%5D%0A%5B1%2C2%2C4%5D%0A%5B1%2C2%2C2%2C1%2C1%2C2%5D%0A%5B1%2C2%2C2%2C1%2C1%2C2%2C1%2C2%2C2%5D%0A%5B1%5D&debug=0)**
[Answer]
# [Red](http://www.red-lang.org), 140 bytes
```
func[b][n: 0 while[(length? b)> 1][l: copy[]parse split form b" "[any[copy s[set t string! thru any t](append l length? s)]]b: l n: n + 1]n]
```
[Try it online!](https://tio.run/##bY3NDoIwEITvPsXICeJFKmrCQd/B62YP/BQhqaVpSwxPj5VEI8RM9rDfZGasrKebrEGMJp@aQVdUMukcezzbTkmKldR3315RJhekTCpH1ZuR2BTWSTijOo@mtw@UESIq9EhvH46c9PBw3nb6voVv7YDgwnNcGCN1DYVPt0uYyzyAMKyxCzuaJxOCoRqUQuAQJALfrGiGI044L/hXP1SsktnqF3NC/KfzLTyeXg "Red – Try It Online")
I just wanted to give Red's Parse dialect another try. 
Ungolfed
```
f: func [b] [
    n: 0
    while [(length? b) > 1][
        l: copy []
        parse split form b " " [
            any [copy s [set t string! thru any t]
                (append l length? s)]
        ]
        b: l
        n: n + 1
    ]
    n
]
```
]