-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathlightsoutlinearmk2.py
58 lines (41 loc) · 1.42 KB
/
lightsoutlinearmk2.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
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
matrices = [[X for X in [0,1]]]
def possiblePresses(gridsize):
numberOfButtons = gridsize**2
subs = subsets(numberOfButtons)
return [X for X in subs]
def subsets(i):
if i == 0:
return[[]]
else:
return induct(subsets(i-1),i)
def induct(listoflists,n):
return listoflists + [X+[n] for X in listoflists]
def createMatrices(dimension):
matrices = [[]]
Matrix(2,2,[1,0,0,1])
Matrix(2,2,[0,1,1,1])
Matrix(2,2,[1,0,1,1])
Matrix(2,2,[1,1,0,1])
Matrix(2,2,[1,1,1,0])
def pressAffect(button, domain):
x1 = ((button[0]-1), button[1])
x2 = ((button[0]+1), button[1])
y1 = (button[0], (button[1]-1))
y2 = (button[0], (button[1]+1))
affected = [x1, x2, y1, y2, button]
return [x for x in affected if (x[0] < domain and x[1] < domain and x[0] >= 0 and x[1] >= 0)]
def translator(list,gridsize):
coordinates = [(X,Y) for X in range(gridsize) for Y in range(gridsize)]
numbers = range(1,gridsize**2+1,1)
converter = {value:key for (key,value) in zip(numbers, coordinates)}
return [converter[x] for x in list]
grid = [(X,Y) for X in range(0, gridsize, 1) for Y in range(0, gridsize, 1)]
buttonAffect = []
for Y in grid:
buttonAffect.append(translator(pressAffect(Y, gridsize),gridsize))
vectorlist = []
for X in range(0,gridsize**4,1):
vectorlist.append(0)
for Z in range(0,len(buttonAffect),1):
for X in buttonAffect[Z]:
vectorlist[X-1+gridsize**2*Z] = 1