Skip to main content
7 of 7
added 80 characters in body
Chas Brown
  • 9.8k
  • 1
  • 13
  • 39

Python 2, 129 126 119 104 bytes

def f(n,k,p=0):z=p<1or n>0;q=-~ord('}/lx2Z^o~z'[n%10])*z;return(z and f(n/10,k,q))+k*bin(p^q).count('1')

Try it online!

Thx for a big 15 bytes from ovs.

As specified, takes a non-negative number and a positive sign length, and returns total changes.

Chas Brown
  • 9.8k
  • 1
  • 13
  • 39