User blog:QuasarBooster/Beklemishev's worms code UPDATE

I wanted to share a slight improvement to the Python that implements worms. The previous version had 108 non-whitespace characters but I managed to reduce it to just 100. I did this by merging the case of the worm's head value being 0 with the case of it being anything else. I actually stumbled upon that improvement by sheer luck, while trying to condense the code that finds where to split the worm into the "good" and "bad" parts. Part of me really thinks that part of code can still be slightly shortened but overall this program isn't realistically gonna get much shorter than it currently is. Suggestions and improvements are welcome! def W(n): k=2 w=[n] while w:   h=w[-1] w[-1]-=1 i=len(w)-1 while(w[i-1]>=h)*i*h:i-=1 w[i:]*=k*(h>0) k+=1 return k-2