-
Notifications
You must be signed in to change notification settings - Fork 0
/
generatomino.py
48 lines (41 loc) · 1.51 KB
/
generatomino.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
import sys
from copy import deepcopy
def generate_minoes(n):
if n==1:
return [[[0,0]]]
possibleminoes = []
oldminoes = generate_minoes(n-1)
for smallminoe in oldminoes:
print(smallminoe)
for square in smallminoe:
if [square[0]-1, square[1]] not in smallminoe:
duplicate_smallminoe = deepcopy(smallminoe)
duplicate_smallminoe.append([square[0]-1, square[1]])
if square[0] < 1:
for squonk in duplicate_smallminoe:
squonk[0] = squonk[0]+1
possibleminoes.append(duplicate_smallminoe)
if [square[0]+1, square[1]] not in smallminoe:
duplicate_smallminoe = deepcopy(smallminoe)
duplicate_smallminoe.append([square[0]+1, square[1]])
possibleminoes.append(duplicate_smallminoe)
if [square[0], square[1]-1] not in smallminoe:
duplicate_smallminoe = deepcopy(smallminoe)
duplicate_smallminoe.append([square[0], square[1]-1])
if square[1] < 1:
for squonk in duplicate_smallminoe:
squonk[1] = squonk[1]+1
possibleminoes.append(duplicate_smallminoe)
if [square[0], square[1]+1] not in smallminoe:
duplicate_smallminoe = deepcopy(smallminoe)
duplicate_smallminoe.append([square[0], square[1]+1])
possibleminoes.append(duplicate_smallminoe)
print("test")
#search for duplicates in possibleminoes
possibleminoes_again = []
for possibleminoe in possibleminoes:
possibleminoe.sort()
if possibleminoe not in possibleminoes_again:
possibleminoes_again.append(possibleminoe)
return(possibleminoes_again)
print(generate_minoes(int(sys.argv[1])))