# [C# (Visual C# Interactive Compiler)], 113 bytes <!-- language-all: lang-cs --> s=>{var t=s;do{s=t;t="";for(int i=0;i<s.Length;)t+=(s[i]-48)*(s[i++]!=(s+0)[i]?1:2*++i/i);}while(t!=s);return t;} [Try it online!][TIO-jqgnrb8r] [C# (Visual C# Interactive Compiler)]: http://www.mono-project.com/docs/about-mono/releases/5.0.0/#csc [TIO-jqgnrb8r]: https://tio.run/##RU47b8IwEN7zK46og40NjU1ADsZ068TeATGE1IClylTxUSpF@e2pQ4Dect/rHlWYVMF17xdfrQLWzh/50NZwANMFs25@yhrQBP15boJBjSZN9eFcE@cRnMm0W4XpxvojnjRFZkjYut0kV3TcI8Z2oyixjEb1TSzlmDH36qhuryf3ZQmOTKC6tnipPaBuO50kcbktqxO5XSg59G1PAW2IBz14e93umgSIlJJDLimPWCxms0huOM@V4qDEYnDmc1FwkJkoBl4UvS0fftEXB6GEugceCfFckcUSMZOJ/5H7jFBRamkC8FE7tBvnLXlJnV9C0z88LVsO9vf7QfeRlhVGeiCDz9KUtinV3R8 "C# (Visual C# Interactive Compiler) – Try It Online" HUGE credit to @ASCIIOnly for golfing 30+ ;) At first we were both posting updates simultaneously, but at some point he clearly went to town! Less golfed code... // s is the input as a string s=>{ // t is another string used // to hold intermediate results var t=s; // the algorithm repeatedly // processes s and saves the // result to t do{ // copy the last result to s // and blank out t s=t; t=""; // iterate over s for(int i=0;i<s.Length;) // append either 1 or 2 times // the current digit to t t+=(s[i]-48)* // compare the current digit // to the next digit. to prevent // an out-of-bounds exception, // append a 0 to s which either // gets ignored or collapses // to 0 (s[i++]!=(s+0)[i] // if they are different, then // the multiplier is 1 ?1 // if they are the same, then // the multiplier is 2, and we // have to increment i :2*++i/i); } // continue this until the input // yields the output while(t!=s); return t; }