mpo100.py

Created by schraf

Created on May 16, 2021

762 Bytes

Le challenge est décrit ici


def mpo(n, z = 0):
  if n == 0: return 0
  q, r = n // 10, n % 10
  if r == 0: return mpo(q, z + 1)
  elif z > 0: return mpo(q, z - 1)
  else: return 10 * mpo(q) + r
  
  
def mpo2(n):
  s, z = "", 0
  while n > 0:
    r, n = n % 10, n // 10
    if r == 0: z += 1
    elif z > 0: z -= 1
    else: 
      s = str(r) + s
  return int("0" + s)
  
def mpo3(n):
  s = []
  for c in str(n):
    s.pop() if c == "0" and len(s) > 0 else s.append(c)
  return int("0" + "".join(s))
  
def mpo4(n):
 s = str(n)
 f = 0
 for i in range(len(s)):
   v = eval(s[i])
   f = 10 *f + v if v else int(f / 10)
 return f
 
def mpobin(n):
  s = z = 0
  while n > 0:
    if 1 & n:
      if z: z -= 1
      else : s = 1 + (s << 1)
    else: z += 1
    n >>= 1
  return s

During your visit to our site, NumWorks needs to install "cookies" or use other technologies to collect data about you in order to:

With the exception of Cookies essential to the operation of the site, NumWorks leaves you the choice: you can accept Cookies for audience measurement by clicking on the "Accept and continue" button, or refuse these Cookies by clicking on the "Continue without accepting" button or by continuing your browsing. You can update your choice at any time by clicking on the link "Manage my cookies" at the bottom of the page. For more information, please consult our cookies policy.