-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcore.py
36 lines (35 loc) · 989 Bytes
/
core.py
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
class grid:
def __init__(self, size = 4):
self.size = size
rows = []
for row in range(size):
rows.append([0] * size)
self.rows = rows
self.columns = invert(self.rows, self.size)
def vertical(self, reverse = False):
out = []
for column in self.columns:
if reverse:
column = column[::-1]
out.append(column)
return out
def horizontal(self, reverse = False):
out = []
for row in self.rows:
if reverse:
row = row[::-1]
out.append(row)
return out
def update(self,rows):
self.rows = rows
self.columns = invert(rows, self.size)
def invert(lines, size = None):
if not size:
size = len(lines)
sideways = []
for col_pos in range(size):
alt = []
for line in lines:
alt.append(line[col_pos])
sideways.append(alt)
return sideways