这是代码:
def isEven (n): #function checks if the number is even or odd
if (int(n)%2) == 0:
True
else:
False
def Edit(b,x,y): #function loops through the number
m = str(b)
for i in range(1, len(m)+1):
if isEven(m[-i]):
continue
elif int(m[-i+(len(m))]) > 5:
b = b + 1
else:
b = b - 1
y = y + 1
x = x + 1
Edit(b,x,y)
number = input()
Number = int(number)
caseNum = 0
moves = 0
Edit(Number,caseNum,moves)
print('Case #' + str(caseNum) + ' : ' + str(moves))
我想创建一个代码来检查数字中是否有奇数位并递增或递减数字直到数字中没有奇数位。
喵喵时光机
墨色风雨
相关分类