Yevhenii Mianovskyi

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
#task1
data = [[5, 4], [2, 3], [0, 2], [1, 4], [2, 0]]
rows = data[0][0]
columns = data[0][0]
array = [[0 for c in range(columns)] for r in range(rows)]
for turn in range(1, len(data)):
row = data[turn][0]
column = data[turn][1]
for i in range(columns):
array[row][i] += 1
for j in range(rows):
if j == row:
pass
else:
array[j][column] += 1
for item in array:
print(item)
# task2
inp = [[5, 1, 9, 11],
[2, 4, 8, 10],
[13, 3, 6, 7],
[15, 14, 12, 16]]
turn = 0
size = len(inp) - 1
while turn < len(inp) / 2.0:
for index in range(turn, (len(inp)-1) - turn):
new_value = inp[turn][index]
old_value = inp[index][size-turn]
inp[index][size-turn] = new_value
new_value = old_value
old_value = inp[size-turn][size-index]
inp[size-turn][size-index] = new_value
new_value = old_value
old_value = inp[size-index][turn]
inp[size-index][turn] = new_value
new_value = old_value
inp[turn][index] = new_value
turn += 1
for item in inp:
print(item)