Last active
May 29, 2017 14:54
-
-
Save Wendly/6faf5fcac9a54a013c16e404538784f7 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
n = int(input()) | |
def translate(index, s): | |
for i in range(1, n + 1): | |
s += str(index[i]) if (index[i - 1] & 1) == 0 else str(9 - index[i]) | |
return s | |
for i in range(0, (10 ** n)): | |
print(translate(list(map(int, str(i).zfill(n + 1))), '')) |
Author
Wendly
commented
May 28, 2017
n = int(input())
l = [[i for i in range(0, 10)], [i for i in range(0, 10)[::-1]]]
dNums = [10 ** i for i in range(0, n)]
def run(num, n, direct, digits):
if n == 0:
print("%0*d" % (digits, num))
else:
for i in range(0, 10):
run(num + dNums[n - 1] * l[direct][i], n - 1, i & 1, digits)
run(0, n, 0, n)
n = int(input())
op = [1, -1]
num = [0] * (n + 1)
for i in range(1, (10 ** n) + 1):
print(''.join(str(i) for i in num[1:]))
s = str(i).zfill(n + 2)
index = 1
while s[-index] == '0':
index += 1
num[-index] = num[-index] + op[int(s[-(index + 1)]) & 1]
n = int(input())
op = [1, -1]
num = [0] * (n + 1)
for i in range(1, (10 ** n) + 1):
print(''.join([str(i) for i in num[0:-1]][::-1]))
s = str(i).zfill(n + 2)[::-1]
index = 0
while s[index] == '0':
index += 1
num[index] = num[index] + op[int(s[index + 1]) & 1]
n = int(input())
numMax = 10 ** n
num = 0
carry = [0] * (n + 2)
dNums = [[10 ** i for i in range(0, n + 2)], [-1 * 10 ** i for i in range(0, n + 2)]]
while num < numMax:
print("%0*d" % (n, num))
carry[0] += 1
index = 0
while carry[index] == 10:
carry[index] = 0
index += 1
carry[index] += 1
num += dNums[carry[index + 1] & 1][index]
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment