-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathRotateMatrix-RawPython.py
More file actions
40 lines (35 loc) · 1.24 KB
/
RotateMatrix-RawPython.py
File metadata and controls
40 lines (35 loc) · 1.24 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
# This is using raw python to solve this problem.
OriginalGrid = [[".", ".", ".", ".", ".", "."],
[".", "0", "0", ".", ".", "."],
["0", ".", "0", "0", ".", "."],
["0", "0", "0", "0", "0", "."],
["0", "0", "0", "0", "0", "0"],
["0", "0", "0", "0", "0", "."],
["0", "0", "0", "0", ".", "."],
[".", "0", "0", ".", ".", "."],
[".", ".", ".", ".", ".", "."]]
while True:
try:
YourInput = int(input("Please input the degree of rotation: "))
if YourInput%90 == 0 and YourInput != 0:
break
print("Oops! That was not valid degree. Try again...")
except ValueError:
print("Oops! That was not valid number. Try again...")
WorkingGrid = OriginalGrid
if YourInput >=0:
Coeff1 = 1
Coeff2 = 0
else:
Coeff1 = 0
Coeff2 = 1
for n in range(abs(int(YourInput/90))):
StandingGrid = []
for b in range((len(WorkingGrid[0])-1)*Coeff2, len(WorkingGrid[0])*Coeff1-Coeff2, Coeff1 -Coeff2):
x = []
for a in range(Coeff1*(len(WorkingGrid) - 1), -Coeff1 +len(WorkingGrid)*Coeff2, -Coeff1 +Coeff2):
x.append(WorkingGrid[a][b])
print(x)
StandingGrid.append(x)
WorkingGrid = StandingGrid
print("\n")