-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpythontest32.py
More file actions
113 lines (90 loc) · 1.81 KB
/
Copy pathpythontest32.py
File metadata and controls
113 lines (90 loc) · 1.81 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
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
import time
import string
dx=9
dy=9
count = 0
mh = [[2,1,2],[1,3,1],[5],[7],[9],[3],[2,3,2],[2,3,2],[2,3,2]]
mv = [[2,1,3],[1,2,3],[3],[8],[9],[8],[3],[1,2,3],[2,1,3]]
#xx x xx
#x xxx x
# xxxxx
# xxxxxxx
#xxxxxxxxx
# xxx
#xx xxx xx
#xx xxx xx
#xx xxx xx
#myFile = open("pythontest32.txt","w")
def checkfigure2(f):
s=""
match=1
for x in range(dx+1):
for y in range(dy):
s = s + f[y*(dx+2)+x]
s=s+chr(10)
ss=s.splitlines()
for i in range(len(ss)-1):
s2 = ss[i+1].strip().split(" ")
t = []
for j in s2:
if j <> '':
t = t + [len(j)]
if t <> mv[i]:
match=0
if match==1:
return True
return False
def checkfigure(f):
s = f.splitlines()
match=1
for x in range(dx):
t=[]
d = 0
e = 0
a=""
for y in range(dy):
a=a+s[y][x+1]
if s[y][x+1]=="X":
if e==0:
e=1
d=d+1
else:
if e==1:
t = t + [d]
e=0
d=0
if d > 0:
t = t + [d]
if t!=mv[x]:
match=0
if match==1:
return True
return False
def placeblock(y,i,n,s,t,f):
global count
for j in range(s+1):
u = t + (" "*(j+1)) + "X"*i[n]
if n < len(i)-1:
placeblock(y,i,n+1,s-j,u,f)
else:
g = f + string.ljust(u,dx+1) + chr(10)
if y<dy-1:
k = mh[y+1]
s = dx - (sum(k)+len(k)-1)
placeblock(y+1,k,0,s,"",g)
else:
count = count + 1
if count%1000==0:
print count,chr(13),
#myFile.write(str(count) + chr(10) + g + chr(10))
if checkfigure2(g) == True:
print count,chr(10) + time.ctime(time.time()) + chr(10) + g
#checkfigure2(g)
print time.ctime(time.time())
i = mh[0]
spacesleft = dx - (sum(i)+len(i)-1)
print i,spacesleft,dx,count
placeblock(0,i,0,spacesleft,"","")
print count
print time.ctime(time.time())
#myFile.close()