[Question]
  [
## Background
Define a **run** in a list as a maximal contiguous subsequence of identical values. For example, the list
```
0 0 0 1 1 0 3 3 3 2 2
```
has five runs of lengths 3, 2, 1, 3, 2 respectively. (Think of run-length encoding.)
Then define a **cut operation** as removing one item from each run of a list. Applied to the list above, the result will be `0 0 1 3 3 2`.
Finally, the **cut resistance** of a list is the number of cut operations needed to reduce it to an empty list. The cut resistance of the list above is 3:
```
0 0 0 1 1 0 3 3 3 2 2
0 0 1 3 3 2
0 3
(empty)
```
Note that the cut resistance can be higher than the maximal run length, since multiple runs may fuse in the way:
```
1 0 0 1 1 0 0 1 0 0 1 0 0 1 0 1 0
0 1 0 0 0
0 0
0
(empty)
```
Related OEIS sequence: [A319416](http://oeis.org/A319416) (cut resistance of n written in binary)
## Task
Given a (possibly empty) list of nonnegative integers, compute its cut resistance.
Standard [code-golf](/questions/tagged/code-golf "show questions tagged 'code-golf'") rules apply. The shortest code in bytes wins.
## Test cases
```
0 0 0 1 1 0 3 3 3 2 2 => 3
1 0 0 1 1 0 0 1 0 0 1 0 0 1 0 1 0 => 4
1 2 3 4 5 99 100 101 => 1
4 4 4 4 4 4 3 3 3 3 2 2 1 2 2 3 3 3 3 4 4 4 4 4 4 => 7
(empty) => 0
```
  
[Answer]
# [J](http://jsoftware.com/), 20 bytes
```
1-~&#(#~2=/\_&,)^:a:
```
[Try it online!](https://tio.run/##y/qvpKeepmBrpaCuoKNgoGAFxLp6Cs5BPm7/DXXr1JQ1lOuMbPVj4tV0NOOsEq3@a3KlJmfkKxgr2CqkAdWCoCEQGgBFQNBIwQiiwASswBBJgQEGCcQQxYZQxUZAE0wUTBUsLRUMDYDyBoYQeXOwvAkSNEbYB9ZnBBdBUgXRbADWrK7@HwA "J – Try It Online")
Using the `0 0 0 1 1 0 3 3 3 2 2` example:
1. `(......_&,)` Prepend infinity `_`:
```
_ 0 0 0 1 1 0 3 3 3 2 2
```
2. `(..2=/....)` Are consecutive pairs equal? Returns 0-1 list of same length as input:
```
_ 0 0 0 1 1 0 3 3 3 2 2  <-- Before
 0 1 1 0 1 0 0 1 1 0 1   <-- After
```
3. `(#~.......)` Apply the above mask as a filter to the input. This drops the first member of every group:
```
0 0 1 3 3 2
```
4. `^:a:` Repeat until we reach a fixed point, returning all intermediate results (0-padded on the right):
```
0 0 0 1 1 0 3 3 3 2 2
0 0 1 3 3 2 0 0 0 0 0
0 3 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0 0
```
5. `1-~&#` Subtract 1 from `1-~` the above result, after applying the "length of" verb to both lists `&#`. Since the length of 1 is 1, it remains unchanged, while the result above becomes 4:
```
4 - 1
3
```
[Answer]
# [Python 2](https://docs.python.org/2/), 55 bytes
```
f=lambda l:l>[]and-~f([x for x in l[1:]if x==l.pop(0)])
```
[Try it online!](https://tio.run/##dY3BCoMwEETv/Yo9JmBLEu1BIf2RkIPFBgPbGCRSe@mvpzFiKZbCYxl2dmb9M/SDEzEaie392rWADV6Ubl13fBmiZjDDCDNYB6h4o62BWUo8@cETRjWNj97iDXjjR@sCGGKdnwKhNCpWwArPJFFuiIQ@KP5zwf6LZa4ZkTuqAs4F1HVy2GIzntwq778pd29zkdhKPuyDqUu/AQ "Python 2 – Try It Online")
False for 0.
**57 bytes**
```
f=lambda l:l>[]and-~f([a for a,b in zip(l,l[1:])if a==b])
```
[Try it online!](https://tio.run/##dY3BCsMgEETv/Yo9KlhQkx4ipD8iHpRUIlgjwVLaQ3/dGkNKSSk8lmFnZzY@0jgFnrPtvb6aQYMX/iyVDsPxZZHUYKcZNDHgAjxdRJ54yYTCzoLue6Nwvo/OX4CJOLuQwCIX4i0hjLOkBFZYpYhmgxfUQbKfC/pfLHPN8NrREjgR6Lri0MWmrLht3X/T7N7WIr6VfNgHS5d6Aw "Python 2 – Try It Online")
[Answer]
# [K (ngn/k)](https://bitbucket.org/ngn/k), 13 bytes
Same as Jonah's, scan of x at where equal each-prior.
```
#1_{x@&=':x}\
```
Using `0 0 0 1 1 0 3 3 3 2 2` as example:
`=':` means equal each prior
```
  =': 0 0 0 1 1 0 3 3 3 2 2  
      0 1 1 0 1 0 0 1 1 0 1  / zeros in the result correspond to the first item of the run
```
then indexing into the argument with this mask effectively drops the first item of each run. the indices are:
```
 &=': 0 0 0 1 1 0 3 3 3 2 2 / where equal each-prior?
1 2 4 7 8 10
 0 0 0 1 1 0 3 3 3 2 2@1 2 4 7 8 10 / indexing 
0 0 1 3 3 2 
```
we can turn this into a function and repeat until the result stops changing
```
 {x@&=':x}\0 0 0 1 1 0 3 3 3 2 2
(0 0 0 1 1 0 3 3 3 2 2
 0 0 1 3 3 2
 0 3
 !0)
```
drop 1 and take the length
```
 #1_{x@&=':x}\0 0 0 1 1 0 3 3 3 2 2
3
```
[Try it online!](https://tio.run/##y9bNS8/7/z/NStkwvrrCQc1W3aqiNuZ/moIBGBoCoYGCMRgaASFXGlgAJmGAQQIxWI0RUIOJgqmCpaWCoQFQ2MAQKGyCBI2RTDUEkzARJFVAPQbKBv8B "K (ngn/k) – Try It Online")
[Answer]
# [05AB1E](https://github.com/Adriandmen/05AB1E/wiki/Commands), 8 [bytes](https://github.com/Adriandmen/05AB1E/wiki/Codepage)
```
.Γγ€¨˜}g
```
[Try it online](https://tio.run/##yy9OTMpM/f9f79zkc5sfNa05tOL0nNr0//@jDXUMgNBQB0ajkkAcCwA) or [verify all test cases](https://tio.run/##yy9OTMpM/V9Waa@k8KhtkoKSfeV/vXOTz21@1LTm0IrTc2rT/@v8j4420AFBQyA00DEGQyMdo1idaEMkcQMMEojBaoyA6k10THUsLXUMDYDCBoZAYRMdBDRGGKpjCCZhIkiqgHpiYwE).
**Explanation:**
```
.Γ        # Continue until the result no longer changes,
          # collecting all intermediate results in a list
  γ       #  Split the list into chunks of equal adjacent elements
   €¨     #  Remove the last value of each chunk
     ˜    #  Flatten the list of lists
      }g  # After the cumulative fixed-point loop, pop and push the length
          # (which is output implicitly as result)
```
[Answer]
# [JavaScript (Node.js)](https://nodejs.org), 38 bytes
```
f=s=>s+s?f(s.filter(t=>s===(s=t)))+1:0
```
[Try it online!](https://tio.run/##ZY/RCoMwDEXf@xV5s05XW3UMN@o@pAqKq@IoKrb4@10tDIXlkgRybgj5tFuru3VczHWa39Lanmte6ki/eqxJPyojV2zchHOONTdhGEbsQe2zmyc9K0nUPOAGCQq7mBOFzCuFtAZeQoYEO0H6V116Y74bU7eZww2KAhh1jDLPGBI5HMqOG8B8/U1OLr94R8J3ihqyykW1ncRJJcilqpMhBvdZj@XWKmwODI4EcRDuYb8 "JavaScript (Node.js) – Try It Online")
# [JavaScript (Node.js)](https://nodejs.org), 42 bytes
```
f=s=>s+s?f(s.filter(t=>s[++i]==t,i=0))+1:0
```
[Try it online!](https://tio.run/##ZY/RCoMwDEXf@xV5s05XW3UMN@o@pAqKq@IoVmzx910tDIXlkgRybgj5tGtrumWc7XXSb7ltPTe8NJF59diQflRWLti6iYiisebcxiOnYRixB92enZ6MVpIoPeAGCQq7mBOFzCuFtAZeQoYEO0H6V116Y74bU7eZww2KAhh1jDLPGBI5HMqOG8B8/U1OLr94R8J3ihqyyFm1ncRJJcilqpMhBvddj@XaKmwPDI4EcRDusX0B "JavaScript (Node.js) – Try It Online")
[Answer]
# [Haskell](https://www.haskell.org/), 41 bytes
```
f[]=0
f(h:t)=1+f[x|(x,y)<-zip(h:t)t,x==y]
```
[Try it online!](https://tio.run/##dY5BCsIwEEX3PcUsXLQYIUkjUnFOErooaGiwtkWzSMW7x3SkYluERxjC@3@mrh7XS9OEYHSJPDFpfXQZiq3R/pV6NmSn3dP29OuYRxzKcKtsCwjnLgHo77Z1sAEDmjP4IIg45BMyUgIi5POIWEX4/2F8qUStSiRtUQz2DIoiqnz0uSBdzHVF4i/54lJaJafWL8sglR/CGw "Haskell – Try It Online")
`f a=1+f[x|(x,y)<-zip a$tail a,x==y]` is the same length.
[Answer]
# [Pyth](https://github.com/isaacg1/pyth), 10 bytes
```
tl.uqF#C,t
```
[Try it online!](https://tio.run/##K6gsyfj/vyRHr7TQTdlZp@T/fxMdBTRkjISMwMgQxkCWQtcIAA "Pyth – Try It Online")
There's a bug in the parser related to this use of `qF#`, because if I append three variables at the end (e.g. `NNQ`), it [crashes the parser](https://tio.run/##K6gsyfj/vyRHr7TQTdlZp8TPL/D/fxMdBTRkjISMwMgQxkCWQtf4L7@gJDM/r/i/bgoA "Pyth – Try It Online"). This is because `qF` should be treated as having arity 1, but it's being treated as having arity 2. However, it works fine as is,
because the rest of the program is implicit, so the parser completes before anything goes wrong.
Explanation:
```
tl.uqF#C,t
  .u          Repeatedly apply the following function until the result stops changing:
         t    Remove the first element of the input (tail)
        ,     Pair with the input
       C      Transpose, resulting in all 2 element sublists.
      #       Filter on
    qF        the two elements being equal.
 l            Length
t             Subtract 1 for the empty list.
```
Note that the intermediate lists look like:
```
[1, 0, 0, 1, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 1, 0]
[[0, 0], [1, 1], [0, 0], [0, 0], [0, 0]]
[[[0, 0], [0, 0]], [[0, 0], [0, 0]]]
[[[[0, 0], [0, 0]], [[0, 0], [0, 0]]]]
[]
```
[Try it online!](https://tio.run/##K6gsyfj/P0uvtNBN2Vmn5P//aEMdBQMwMgQjOBsrA0TGAgA "Pyth – Try It Online")
This occurs because the program doesn't both to select one element from each pair of numbers. Instead, the pair itself is used as the element of the list in the next iteration. This saves 2 bytes.
[Answer]
# [Wolfram Language (Mathematica)](https://www.wolfram.com/wolframscript/), 38 bytes
```
If[#!={},#0[Join@@Rest/@Split@#]+1,0]&
```
[Try it online!](https://tio.run/##y00syUjNTSzJTE78n2773zMtWlnRtrpWR9kg2is/M8/BISi1uETfIbggJ7PEQTlW21DHIFbtf0BRZl6Jgr5Dur5DdbWBDggaAqGBjjEYGukY1epUGyKJG2CQQAxWYwRUb6JjqmNpqWNoABQ2MAQKm@ggoDHCUB1DMAkTQVIF1FNb@/8/AA "Wolfram Language (Mathematica) – Try It Online")
[Answer]
# [Perl 5](https://www.perl.org/) `-p`, 32 bytes
```
$\++while s/\b(\d+ )(\1*)/$2/g}{
```
[Try it online!](https://tio.run/##K0gtyjH9rxKvZ6uuoJ6ZpqivoKJv/V8lRlu7PCMzJ1WhWD8mSSMmRVtBUyPGUEtTX8VIP722@v9/QwUDIDRUgNGoJAj/yy8oyczPK/6vWwAA "Perl 5 – Try It Online")
Requires a trailing space on the input. (Though I did put some code in the header to add it if it isn't already there so that testing is easier.)
[Answer]
# [Prolog](https://github.com/mthom/scryer-prolog), 115 bytes
```
a([_],[]).  
b(_,[],E,E).    
b(A,[B|C],D,E):-A=B,b(A,C,[B|D],E);b(B,C,D,E).   
c(A,B):-A=[],B=0;A=[P|L],b(P,L,[],C),!,c(C,D),B is D+1.
```
Clear version:
```
% Cut operation.
% Cut operation.
% Previous A, Head B, Tail C, List D, List E.
b(_, [], E, E).
b(A, [B|C], D, E) :-
    A = B,
    b(A, C, [B|D], E)
;   b(B, C, D, E).
% Count cut.
% List A, Number of cut B.
c(A, B) :-
    A = [],
    B = 0
;   A = [P|L],
    b(P, L, [], C),!,
    c(C, D),
    B is D + 1.
```
[Answer]
# [Husk](https://github.com/barbuz/Husk), 7 bytes
```
←V¬¡Ψf=
```
[Try it online!](https://tio.run/##yygtzv7//1HbhLBDaw4tPLcizfb////RhjogaASGxkAIZsUCAA "Husk – Try It Online")
## Explanation
It's not often that I get to use the higher order modifier function `Ψ`, but here it's very convenient.
```
←V¬¡Ψf=   Implicit input: a list.
   ¡      Iterate (producing an infinite list)
     f    filtering by condition:
    Ψ     the next element
      =   is equal to this one.
          The last element is always discarded.
 V        1-based index of first result that is
  ¬       falsy (for lists, this means empty).
←         Decrement.
```
[Answer]
# [APL (dzaima/APL)](https://github.com/dzaima/APL), 18 bytes
```
≢1↓{⍵⊇⍨⍸2=/¯1,⍵}⍡≡
```
`{⍵⊇⍨⍸2=/¯1,⍵}` - dfn that finds the next stage
`⍡≡` iterate until reaching a fixpoint
`≢2↓` drop the first two elements, then take the length
-2 bytes thanks to Marshall
-1 byte thanks to Bubbler
[Try it online!](https://tio.run/##SyzI0U2pSszMTfz/P@1R24RHnYuMHrVNrn7Uu/VRV/uj3hWPencY2eofWm@oAxSqfdS78FHnwv@P@qYC1aYpGIChIRAaKBiDoZGCERdM1hBJ1gCDBOL/AA "APL (dzaima/APL) – Try It Online")
[Answer]
# T-SQL, 125 bytes
I am [using table as input](https://data.stackexchange.com/stackoverflow/query/1244049/cut-resistance-of-a-list)
```
DECLARE @ INT=1u:SET
@-=1DELETE x FROM(SELECT*,lag(a,1,-1)over(order by i)b
FROM t)x
WHERE a<>b
IF @@rowcount>0GOTO u
PRINT-@
```
The posted code is using a permanent table as input. **[Try it online](https://data.stackexchange.com/stackoverflow/query/1244049/cut-resistance-of-a-list)** is using a table variable spending 1 additional byte
[Answer]
# [R](https://www.r-project.org/), ~~56~~ 55 bytes
```
f=function(x)`if`(sum(x|1),1+f(x[-cumsum(rle(x)$l)]),0)
```
[Try it online!](https://tio.run/##ZY3BCoMwDIbve44dEpZBUt3Bg08yBkKxIKiDaqEH372LMrVj/OQn5P@S@GTD7NupTq52YbRz9x4hYtO5BqYwQFwESW4O4vNuw7COfN8qce3xhcT43QcLTKtExVRsMmQQLwcgGcB/rvULG71Q0oOqioQ1Z8nzkk4V5z@SzfdJRuXL2qcP "R – Try It Online")
*Edit: recursive function is 1 byte shorter, and returns `0` for empty input*
([original](https://tio.run/##K/r/v8K2ODkxT0PTujwjMydVo7g0V6OixlBTs7rCtiJaN7k0FyRSBJSp0FTJ0Yy1drN10zastXb7b6KAgMZQaASEhmASJoKk6j8A), non-recursive version returned FALSE for empty input)
[Answer]
# [Brain-Flak](https://github.com/DJMcMayhem/Brain-Flak), 68 bytes
```
([]){{}({}()<>)<>([])}<>({()<{(({}<>)<>[({})]){{}<>{}(<>)}{}}<>>}{})
```
[Try it online!](https://tio.run/##SypKzMzTTctJzP7/XyM6VrO6ulYDiDRt7IAIJFALpKqB/GoNoDhYNBrI0ASrtLEDKgWK1VbXAtl2QErz/39DBQMgNFSA0agkEAMA "Brain-Flak – Try It Online")
```
([]){{}({}()<>)<>([])}<>  # add 1 to everything so I don't have to handle 0
({()<                     # until stack is "empty", counting iterations:
  {                       # for each number
    (
      ({}<>)              # copy to other stack
    <>[({})])             # and compare to next number (or zero if at end)
    {{}<>{}(<>)}{}        # if not equal, remove newly added number
  }<>                     # switch stacks for next iteration
>}{})                     # output number of iterations
```
[Answer]
# [C (gcc)](https://gcc.gnu.org/), ~~108~~ ~~104~~ 101 bytes
* Saved ~~four~~ seven bytes thanks to [ceilingcat](https://codegolf.stackexchange.com/users/52904/ceilingcat).
```
*o,*O,r;e(int*s){for(r=1;~*s;r++)for(o=s;~*o;*O=-1){for(;*o==*++o;);for(O=--o;~*O;)*O++=O[1];}s=~-r;}
```
[Try it online!](https://tio.run/##dVHda8IwEH/vX3F0CEmaQqOO4UIme3AwGBQ296Q@SG2l0DbSdMNN6r/eXVo/hm7hCHe938flGvnrKGoapjkLeSljkhYVM3SX6JKUSsg9M7L0PGprrQzWWrJQ@aKDSKaVYp6nJZW2xo6vERRKykLPU@FMLGRt1N4vZd3crOIkLWKYTmAHaATVbAEKc@fYeZuSeLuh4AuoJeRxHm2@SMah4kBM@h3rBCrwQFBgcKjtxJRKmDtwcazDWlfoEJPsT8SGVPh9UyIyIW5vBWMFeJOeofPC5ZbNAQfif3BbZWW7MAbXfERRbIwL9@A@PT6/vL9OXJSunU@drtDHzsIyCjvnZLdDgAPtFrHlCQkZLhp9zvNwwCGQJs@sGvYP0Ek7VjRfpgVpdTsLfG2@zDIdkWCb4DkvqtPB3Qf8EKINTAbH6LeBf2FAW6i4ggb/J92N5OGJ3G9VhxxuOYxGCAksLhAtTHSwIb@MwdVE4pj8bl0TUfSuE8UsoE7d/AA "C (gcc) – Try It Online")
[Answer]
# [Factor](https://factorcode.org/) + `grouping.extras`, 78 bytes
```
[ 0 swap [ [ ] group-by values [ rest ] map-concat [ 1 + ] dip ] until-empty ]
```
[Try it online!](https://tio.run/##ZVDLasMwELz7K6bn4iDFLiXNB5Recik9mRxUdZua2LIirduakG9312oDgjJoWObBsno3locwvzw/7R4fcAjD6Ft3WNE3BxNhYhxsRKTTSM5SNl0TRwqOOvSGP@ADMU8@tI6xLc4FcIZK0AKFKmEtuOAGVfJ15qt/vLwlW/9l19KvcYfNBlqJrXSydbLrDFW2TCe@Knlq6d6n7jKp4jI3sjB@GY9GsP/9j/J1wqfpRjm/QaDIYvTGl3Zw1rBoGrcivbVeeHTcdiX1nifsZ4khsrHH1fwD "Factor – Try It Online")
## Explanation:
It's a quotation (anonymous function) that takes a sequence from the data stack as input and leaves an integer on the data stack as output.
* `0 swap` Tuck away our cut resistance value for safe keeping.
* `[ ... ] until-empty` Keep doing something to a sequence until it's empty. This is shorter than having to call `dup`, `empty?`, `drop`, and the like.
* `[ ] group-by values` Group the runs of a sequence. This is shorter than `[ = ] monotonic-split`.
* `[ rest ] map-concat` Cut the runs and glue 'em back together.
* `[ 1 + ] dip` Increment the cut resistance value.
[Answer]
# [Vyxal](https://github.com/Vyxal/Vyxal), 7 bytes
```
≬ĠvṪfİL
```
[Try it Online!](https://vyxal.pythonanywhere.com/#WyIiLCIiLCLiiazEoHbhuapmxLBMIiwiIiwiWzAsIDAsIDAsIDEsIDEsIDAsIDMsIDMsIDMsIDIsIDJdIl0=)
```
     İL # Count number of times until the result repeats
≬----   # By applying the following
 Ġ      # Group consecutive elements
  vṪ    # Remove the last item from each group
    f   # Flatten
```
[Answer]
# [Python 2](https://docs.python.org/2/), 63 bytes
Takes in a string \$ s \$, a space-separated string of the numbers. It returns `False` for the *empty* case.
```
f=lambda s:s>''and-~f(re.sub(r'(\d+ )(\1*)',r'\2',s))
import re
```
[Try it online!](https://tio.run/##ZYzLCoMwEEX3@YrZJWmtJGopCvojtZS0KgZ8hCQi3fTX7SiUCuUwdzH3zJiXb8chWpYm71T/qBS4zBWUqqE6vRtm69BND2YpK6sjcFbKA6eBpWVEA8c50b0ZrQdbL3OruxpkRuCpXA05WDXf9WAmz3joTKc9o3kBlBMwVg8eGraKV3Hji4AViQiINyIE7ZjIXSX@ch3UEtQivErgDGkKUmAj5NpIksCPePddbvnd7C08uxAM8QE "Python 2 – Try It Online")
---
## [Python 2](https://docs.python.org/2/), 65 bytes
Same as above, but returns `0` for the *empty* case, in case returning false is disallowed.
```
f=lambda s:len(s)and-~f(re.sub(r'(\d+ )(\1*)',r'\2',s))
import re
```
[Try it online!](https://tio.run/##ZYzRCoIwFIbv9xTnbltZbGqEgb1IRsycONA5tkV006vbUYiE@Dj/xfm/c9wrdqNNp6ktezXUjYJw6rVlgSvb7N4t83ofHjXzlFXNFjir5IbTxNMqpUngnJjBjT6C19OzM70GeSJwV0FDCV49b8a6R2R8H1xvIqPlGSgn4LyxEVo2ixdx5ZOAGYkIyBZSBO2MyFUl/nIe1HLUUrzK4QBFAVJgI@TcSJLDj2z1XS753awtPDsSDPEB "Python 2 – Try It Online")
[Answer]
# [Factor](https://factorcode.org/), 109 bytes
```
: f ( s -- n ) 0 swap [ dup empty? ]
[ [ = ] monotonic-split [ 1 tail ] map concat
[ 1 + ] dip ] until drop ;
```
[Try it online!](https://tio.run/##ZU89a8MwFNz9K25sKApSkg5xKB0ylCxZSqeQQdhyKmpLqvRMCcG/3X02iTFUhx7oPnS8ShfkY//5cTi@5/g20ZkajaYvJPPTGleYhBRqS2TdZdl458k7WyBEQ3QN0TrCLjscc@xbEtEkm0hzSvhKaFHzq89R4QkJQsBhAYn0qwNOKNsA0wS6vuGcnZh4xRlTgxhbmVUgbetB4lThXaEpG9hnpkobeLaO2FBGH7Drbxn43LhmgGJIrEesGN1dVTNV/pvD7TBZVxze4AXbLZRkVarpn80M61mPGueDmbseyS7reLnqvtey/wM "Factor – Try It Online")
[Answer]
# [Retina 0.8.2](https://github.com/m-ender/retina/wiki/The-Language/a950ad7d925ec9316e3e2fb2cf5d49fd15d23e3d), ~~27~~ 25 bytes
*-2 bytes thanks to @Neil*
```
1`\b
=
}`(\d+ )(\1*)
$2
=
```
[Try it online!](https://tio.run/##K0otycxL/K@qkaDCpcCl4Z7w3zAhJonLlqs2QSMmRVtBUyPGUEuTS8WIy/b/fwMFEDQEQgMFYzA0AkIuQyRhAwwSiIEqjICKTRRMFSwtFQwNgIIGhlwmCghojGSeIZiEiSCr4lIAAA "Retina 0.8.2 – Try It Online")
Similar to @Xcali's Perl solution, and similarly requires a trailing space in the input.
```
1`\b
=
```
Replace the first word-boundary with a `=` character. The first time this is executed, it will match the start of the input. On subsequent runs, it will match the empty space between a `=` and the first number in the list
```
(\d+ )(\1*)
$2
```
Replace sequences of repeated integers with everything but the first integer.
```
}`
```
Execute the preceding two stages in a loop until the input stops changing
```
=
```
Count the number of `=`'s
[Answer]
# [Jelly](https://github.com/DennisMitchell/jelly), ~~9~~ 8 [bytes](https://github.com/DennisMitchell/jelly/wiki/Code-page)
-1 by golfing a 9-byter suggested by clapp
```
EƝTịµƬL’
```
**[Try it online!](https://tio.run/##y0rNyan8/9/12NyQh7u7D209tsbnUcPM////RxvqKBiAkSEYwdlYGSAyFgA "Jelly – Try It Online")**
[Answer]
# [C (gcc)](https://gcc.gnu.org/), ~~118~~ \$\cdots\$ ~~94~~ 92 bytes
Saved ~~2~~ ~~5~~ 7 bytes thanks to [ceilingcat](https://codegolf.stackexchange.com/users/52904/ceilingcat)!!! 
```
*t;k;c;f(l,n)int*l;{for(k=0;n;++k)for(t=l,c=-1;t-l<n;)c-*t?c=*t,wmemcpy(t,t+1,n--):++t;c=k;}
```
[Try it online!](https://tio.run/##vVHbaoNAEH3vVwxCgroj9UpJN7YPpV@R5CFstBWNCbrQtOK3242rqbFUsEhklL3MuTnMeGOsqnROY8poqCaYalHK9YQW4SFTY9@kKSUk1s477ifIfMOi3EiWKdWYofNn5uscP/bBnh0/VY6cWJgahvZICKfMj2lZBZhjRO/22yhVNSjuQDxCA3iQ89xabcCHwkSQZdUlFk5btqiSXqNsibJ@ocy/F@dvn8e58Ni1lovgISwWots8Q0yrj3Alwq17u@X0LNeCdkt8qT6wz@9J/s5xcDoGjMtjSSCIH37CsPdtpmfyXlmfXu31afEiXk9B6O4dRQBqxDETvKGqFIomKcRwQY0EgUkhgiXk0VdwCFU5IO2@2QqQRoGQqB1i7XA@b@mEXMPXFZntFGwmHW2a@/LKRtnCcuGgVcUBE017iwfjCWY7mOXrVHjIEbJV888CQja@n59lxwe3pwpujwlu44CJ2wR3pgrujAnu4ICJ2wR3pwrujgnu4oCJ2wT3pgrujQnu4YCJ/wQvq28 "C (gcc) – Try It Online")
**Commented code**
```
*t;k;c;f(l,n)int*l;{
  for(k=0;                  /* initialise cut operation counter */
    n;                      /* loop until there're no numbers left 
                                     in array */
    ++k)                    /* increment cut operation counter after
                                     every loop */
     for(t=l,               /* save the pointer to the start of 
                                     the array */
       c=-1;                /* initialise c to something that won't
                                     match first number */
       t-l<n;)              /* loop until our temp pointer is past 
                                     the end of the array */
        c-*t?               /* should we do a cut operation? */
         c=*t,              /* save our cuurent number so we do a cut
                                     operation at next different number */
         wmemcpy(t,t+1,n--) /* shift array down one element
                                     and reduce number of elements by 1 */
         :++t;              /* if we're not doing a cut operation
                                     bump pointer */
  c=k;                      /* return k */
}
```
[Answer]
## Clojure, 72 bytes
```
#(count(take-while seq(iterate(fn[c](mapcat rest(partition-by + c)))%)))
```
Damn these function names are long :D
[Answer]
# [Charcoal](https://github.com/somebody1234/Charcoal), 22 bytes
```
Ｗθ«≔Φθ∧λ⁻κ§θ⊖λθ⊞υω»ＩＬυ
```
[Try it online!](https://tio.run/##XYvLCoMwEEXX5itmOYF00cfOlbQUCi24Fxeig4bGKSaxFkq/PY2Fgjicxb2cO3VX2fpRmRCmThsCHCS8RZI5p1vGszaeLA4KMm7QKLhpHh3eY/cXbug1qxPVlnpiT3Ei51MwyFQk@eg6HBVMsXxEbjV7PFbO45W49VHFaRpCURwUrNgv2P3Y/sNSrR/LMmye5gs "Charcoal – Try It Online") Link is to verbose version of code. Explanation:
```
Ｗθ«
```
Repeat until the input list is empty.
```
≔Φθ∧λ⁻κ§θ⊖λθ
```
Filter out the first term and any terms equal to their predecessor, i.e. the first of every run.
```
⊞υω
```
Keep track of the number of iterations.
```
»ＩＬυ
```
Output the number of iterations.
[Answer]
# [Japt](https://github.com/ETHproductions/japt), 9 [bytes](https://en.wikipedia.org/wiki/ISO/IEC_8859-1)
```
Ê©ÒßUòÎcÅ
```
[Try it](https://petershaggynoble.github.io/Japt-Interpreter/?v=1.4.6&code=yqnS31XyzmPF&input=WzAgMCAwIDEgMSAwIDMgMyAzIDIgMl0)
```
Ê©ÒßUòÎcÅ     :Implicit input of array U
Ê             :Length
 ©            :Logical AND with
  Ò           :Negate the bitwise NOT of
   ß          :Recursive call with argument
    Uò        :  Partition U between elements where
      Î       :    The sign of their difference is truthy (not 0)
       c      :  Flatten after
        Å     :    Slicing off the first element of each partition
```
[Answer]
# [Husk](https://github.com/barbuz/Husk), ~~8~~ 7 bytes
```
←LU¡mhg
```
[Try it online!](https://tio.run/##yygtzv7//1HbBJ/QQwtzM9L///8fbaADgoZAaKBjDIZGOkaxAA "Husk – Try It Online")
A different method, which is ~~slightly longer~~ now the same length.
## Explanation
```
←LU¡mhg
      g group runs of consecutive equal elements
   ¡    apply function infinitely, collecting it's results
    mh  drop the last element from each run
  U     cut at fixed point
←L      Get length, decrement.      
```
[Answer]
# [Ruby](https://www.ruby-lang.org/) `-nl`, 43 bytes
Similar to the other regex-based answers.
```
$.+=1while gsub(/(\d+ )(\1*)/,'\2')!=""
p$.
```
[Attempt This Online!](https://ato.pxeger.com/run?1=m72kqDSpcnm0km5ejlLsgqWlJWm6Fje1VfS0bQ3LMzJzUhXSi0uTNPQ1YlK0FTQ1Ygy1NPV11GOM1DUVbZWUuApU9CBaoDoX3DQyUUBAYyg0AkJDMAkTQVYF0QoA)
]