-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.py
More file actions
68 lines (52 loc) · 2.15 KB
/
Copy pathmain.py
File metadata and controls
68 lines (52 loc) · 2.15 KB
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
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
# This is a sample Python script.
# Press Shift+F10 to execute it or replace it with your code.
# Press Double Shift to search everywhere for classes, files, tool windows, actions, and settings.
Matrix3D = []
MatrixNull = [[0, 0, 0], [0, 0, 0], [0, 0, 0]]
MatrixBracket = [["┌", "┐"], ["|", "|"], ["└", "┘"]]
def PrintMatrix(matrix):
# Hpw many arrays to print
for i in range(0, 3):
print(f"{MatrixBracket[i][0]}{formatMatrixRow(matrix[i], 3)}{MatrixBracket[i][1]}")
def formatMatrixRow(row, width):
return (f"{str.center(str(row[0]), width, ' ')} "
f"{str.center(str(row[1]), width, ' ')} "
f"{str.center(str(row[2]), width, ' ')} ")
# https://stackoverflow.com/questions/434287/how-to-iterate-over-a-list-in-chunks
def chunker(seq, size):
return (seq[pos:pos + size] for pos in range(0, len(seq), size))
def PrintMatrixList(matrixLst, cols):
for group in chunker(matrixLst, cols):
s = ""
for row in range(3):
for m in range(cols):
if m >= len(group):
s = s + f"{MatrixBracket[row][0]}{formatMatrixRow(MatrixNull[row], 3)}{MatrixBracket[row][1]}\t"
else:
s = s + f"{MatrixBracket[row][0]}{formatMatrixRow(group[m][row],3)}{MatrixBracket[row][1]}\t"
print(s)
s = ""
print("")
def EnteredMatrix():
# for i in range(0, 3):
# row = input(f"Enter in row {i + 1} : ")
# row = row.replace(" ", "")
# rowSplit = row.split(',')
# if len(rowSplit) != 3:
# print(f"Syntax Error : {rowSplit}")
# exit()
# rowArray = []
# for j in range(0, 3):
# rowArray.append(int(rowSplit[j]))
# Matrix3D.append(rowArray)
lst = [ ]
lst.append([[1, 1, 1], [2, 2, 2], [3, 3, 3]])
lst.append([[4, 4, 4], [5, 5, 5], [6, 7, 7]])
lst.append([[7, 7, 7], [8, 8, 8], [9, 9, 9]])
PrintMatrix(lst[1])
print("")
PrintMatrixList(lst, 1)
# Press the green button in the gutter to run the script.
if __name__ == '__main__':
EnteredMatrix()
# See PyCharm help at https://www.jetbrains.com/help/pycharm/