Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- theNum#TASK4
- import numpy as np
- n = int(input())
- a = np.array([range(n*n)])
- a = np.zeros([n, n], dtype = int)
- diag = True
- changedirection = False
- theNum = 0
- i = 0
- j = 0
- while theNum < n*n:
- a[i,j] = theNum
- if diag:
- j+=1
- i-=1
- if j == n:
- j-=1
- i+=2
- changedirection = True
- elif i < 0:
- i+=1
- changedirection = True
- if not diag:
- j-=1
- i+=1
- if i == n:
- i-=1
- j+=2
- changedirection = True
- elif j < 0:
- j+=1
- changedirection = True
- if changedirection:
- diag = not diag
- changedirection = False
- theNum = theNum + 1
- print(a)
- #TASK6
- keys = [0, 1, 2, 3, 4 , 5, 6, 7 ,8 ,9 , "A", "B" , "C", "D", "E", "F"]
- def deep(ans, n, m):
- if len(ans) == n:
- print(ans)
- ans = ''
- return
- for i in range(m):
- deep(ans+str(keys[i]),n, m)
- def back(n, m):
- ans = ''
- deep(ans, n, m)
- back(int(input()), int(input()))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement