Changeset - 5b557313c5f2
[Not reviewed]
default
0 3 0
Laman - 7 years ago 2018-06-28 17:43:01

úprava na ostrá data
3 files changed with 172 insertions and 164 deletions:
dlx.py
9
5
piece_list.py
149
149
tetris.py
14
10
0 comments (0 inline, 0 general)
dlx.py
Show inline comments
 
@@ -77,19 +77,20 @@ class Header(Column):
 
		while row is not col:
 
			self._res[k]=row
 
			c=row.right
 
			while c is not row:
 
				c.col.cover()
 
				c=c.right
 
			self.search(k+1)
 
			if self.search(k+1): return True
 
			c=row.left
 
			while c is not row:
 
				c.col.uncover()
 
				c=c.left
 
			row=row.down
 
		col.uncover()
 
		return False
 

	
 
	def chooseCol(self):
 
		c=self.right
 
		best=c.size
 
		res=c
 
		while c is not self:
 
@@ -97,14 +98,17 @@ class Header(Column):
 
				best=c.size
 
				res=c
 
			c=c.right
 
		return res
 

	
 
	def print(self):
 
		res=[]
 
		for r in self._res:
 
			print(r.col.name,end=" ")
 
			res.append([])
 
			res[-1].append(r.col.name)
 
			c=r.right
 
			while c is not r:
 
				print(c.col.name,end=" ")
 
				res[-1].append(c.col.name)
 
				c=c.right
 
			print()
 
		print()
 
			res[-1].sort(key=str)
 
		for line in res:
 
			print(line)
piece_list.py
Show inline comments
 
pieces=[
 
	("1+2",[[
 
	((1,2),[[
 
		[1,1,1,1],
 
		[1,0,0,0],
 
		[1,0,0,0],
 
		[1,0,0,0]
 
	]]),
 
	("1+3",[[
 
	((1,3),[[
 
		[1,1,1,1,1],
 
		[1,0,0,0,0],
 
		[1,0,0,0,0]
 
	]]),
 
	("1+3_",[[
 
	((1,3),[[
 
		[1,1,1,1],
 
		[1,1,1,0]
 
	]]),
 
	("1+4",[[
 
	((1,4),[[
 
		[1,1,1,1,1],
 
		[1,0,0,0,0],
 
		[1,0,0,0,0]
 
	]]),
 
	("1+4_",[[
 
	((1,4),[[
 
		[1,0,0,0],
 
		[1,0,0,0],
 
		[1,0,0,0]
 
	],[
 
		[0,0,0,0],
 
		[0,0,0,0],
 
		[1,1,1,1]
 
	]]),
 
	("1+5",[[
 
	((1,5),[[
 
		[1,1,1,1,0,0],
 
		[0,0,0,1,1,1]
 
	]]),
 
	("1+5_",[[
 
	((1,5),[[
 
		[1,1,1,1,1],
 
		[1,0,0,0,0],
 
		[1,0,0,0,0]
 
	]]),
 
	("1+6",[[
 
	((1,6),[[
 
		[1,1,1,1,1],
 
		[1,0,0,0,0],
 
		[1,0,0,0,0]
 
	]]),
 
	("1+6_",[[
 
	((1,6),[[
 
		[1,0,0,0],
 
		[1,0,0,0],
 
		[1,0,0,0]
 
	],[
 
		[1,1,1,1],
 
		[0,0,0,0],
 
		[0,0,0,0]
 
	]]),
 
	("1+7",[[
 
	((1,7),[[
 
		[1,1,1,1],
 
		[1,1,1,0]
 
	]]),
 
	("1+7_",[[
 
	((1,7),[[
 
		[1,0,0,0],
 
		[1,0,0,0],
 
		[1,0,0,0]
 
	],[
 
		[1,1,1,1],
 
		[0,0,0,0],
 
		[0,0,0,0]
 
	]]),
 
	("1+8",[[
 
	((1,8),[[
 
		[1,1,1,1],
 
		[1,1,1,0]
 
	]]),
 
	("1+8_",[[
 
	((1,8),[[
 
		[1,0,0,0],
 
		[1,0,0,0],
 
		[1,0,0,0]
 
	],[
 
		[0,0,0,0],
 
		[0,0,0,0],
 
		[1,1,1,1]
 
	]]),
 
	("1+9",[[
 
	((1,9),[[
 
		[1,1,1,1,0,0],
 
		[0,0,0,1,1,1]
 
	]]),
 
	("1+9_",[[
 
	((1,9),[[
 
		[1,0,0,0],
 
		[1,0,0,0],
 
		[1,0,0,0]
 
	],[
 
		[0,0,0,0],
 
		[0,0,0,0],
 
		[1,1,1,1]
 
	]]),
 
	("1+10",[[
 
	((1,10),[[
 
		[1,1,1,1,0,0],
 
		[0,0,0,1,1,1]
 
	]]),
 
	("1+10_",[[
 
	((1,10),[[
 
		[1,0,0,0],
 
		[1,0,0,0],
 
		[1,0,0,0]
 
	],[
 
		[1,1,1,1],
 
		[0,0,0,0],
 
		[0,0,0,0]
 
	]]),
 
	("1+11",[[
 
	((1,11),[[
 
		[1,1,1,1,0],
 
		[0,0,1,1,1]
 
	]]),
 
	("1+11_",[[
 
	((1,11),[[
 
		[1,0,0,0,0],
 
		[1,1,1,1,1],
 
		[1,0,0,0,0]
 
	]]),
 
	("1+12",[[
 
	((1,12),[[
 
		[1,0,0,0,0],
 
		[1,1,1,1,1],
 
		[1,0,0,0,0]
 
	]]),
 
	("1+12_",[[
 
	((1,12),[[
 
		[1,0,0,0],
 
		[1,0,0,0],
 
		[1,0,0,0]
 
	],[
 
		[0,0,0,0],
 
		[1,1,1,1],
 
		[0,0,0,0]
 
	]]),
 
	("1+13",[[
 
	((1,13),[[
 
		[1,1,1,1,0],
 
		[0,0,1,1,1]
 
	]]),
 
	("1+13_",[[
 
	((1,13),[[
 
		[1,0,0,0],
 
		[1,0,0,0],
 
		[1,0,0,0]
 
	],[
 
		[0,0,0,0],
 
		[1,1,1,1],
 
		[0,0,0,0]
 
	]]),
 
	("1+14",[[
 
	((1,14),[[
 
		[1,1,1,1,0],
 
		[0,0,1,1,1]
 
	]]),
 
	("1+14_",[[
 
	((1,14),[[
 
		[1,0,0,0],
 
		[1,0,0,0],
 
		[1,0,0,0]
 
	],[
 
		[0,0,0,0],
 
		[1,1,1,1],
 
		[0,0,0,0]
 
	]]),
 
	("2+3",[[
 
	((2,3),[[
 
		[1,0,0,0],
 
		[1,0,0,0],
 
		[1,0,0,0]
 
	],[
 
		[1,1,1,1],
 
		[0,0,0,0],
 
		[0,0,0,0]
 
	]]),
 
	("2+3_",[[
 
	((2,3),[[
 
		[1,0,0,0],
 
		[1,0,0,0],
 
		[1,0,0,0]
 
	],[
 
		[0,0,0,0],
 
		[0,0,0,0],
 
		[1,1,1,1]
 
	]]),
 
	("2+4",[[
 
	((2,4),[[
 
		[1,1,1,1],
 
		[1,1,1,0]
 
	]]),
 
	("2+4_",[[
 
	((2,4),[[
 
		[1,1,1,1,0,0],
 
		[0,0,0,1,1,1]
 
	]]),
 
	("2+5",[[
 
	((2,5),[[
 
		[1,0,0,0],
 
		[1,0,0,0],
 
		[1,0,0,0]
 
	],[
 
		[0,0,0,0],
 
		[0,0,0,0],
 
		[1,1,1,1]
 
	]]),
 
	("2+5_",[[
 
	((2,5),[[
 
		[1,0,0,0],
 
		[1,0,0,0],
 
		[1,0,0,0]
 
	],[
 
		[1,1,1,1],
 
		[0,0,0,0],
 
		[0,0,0,0]
 
	]]),
 
	("2+6",[[
 
	((2,6),[[
 
		[1,1,1,1],
 
		[1,1,1,0]
 
	]]),
 
	("2+6_",[[
 
	((2,6),[[
 
		[1,1,1,1,0,0],
 
		[0,0,0,1,1,1]
 
	]]),
 
	("2+7",[[
 
	((2,7),[[
 
		[1,1,1,1,1],
 
		[1,0,0,0,0],
 
		[1,0,0,0,0]
 
	]]),
 
	("2+8",[[
 
	((2,8),[[
 
		[1,1,1,1,1],
 
		[1,0,0,0,0],
 
		[1,0,0,0,0]
 
	]]),
 
	("2+9",[[
 
	((2,9),[[
 
		[1,1,1,1,1],
 
		[1,0,0,0,0],
 
		[1,0,0,0,0]
 
	]]),
 
	("2+10",[[
 
	((2,10),[[
 
		[1,1,1,1,1],
 
		[1,0,0,0,0],
 
		[1,0,0,0,0]
 
	]]),
 
	("2+11",[[
 
	((2,11),[[
 
		[1,0,0,0],
 
		[1,0,0,0],
 
		[1,0,0,0]
 
	],[
 
		[0,0,0,0],
 
		[1,1,1,1],
 
		[0,0,0,0]
 
	]]),
 
	("2+12",[[
 
	((2,12),[[
 
		[1,1,1,1,0],
 
		[0,0,1,1,1]
 
	]]),
 
	("2+13",[[
 
	((2,13),[[
 
		[1,0,0,0,0],
 
		[1,1,1,1,1],
 
		[1,0,0,0,0]
 
	]]),
 
	("2+14",[[
 
	((2,14),[[
 
		[1,0,0,0,0],
 
		[1,1,1,1,1],
 
		[1,0,0,0,0]
 
	]]),
 
	("3+4",[[
 
	((3,4),[[
 
		[1,0,0],
 
		[1,0,0],
 
		[1,0,0]
 
	],[
 
		[1,0,0],
 
		[0,0,0],
 
		[0,0,0]
 
	],[
 
		[1,1,1],
 
		[0,0,0],
 
		[0,0,0]
 
	]]),
 
	("3+4_",[[
 
	((3,4),[[
 
		[1,0,0],
 
		[1,1,1],
 
		[0,0,0]
 
	],[
 
		[1,0,0],
 
		[1,0,0],
 
		[1,0,0]
 
	]]),
 
	("3+5",[[
 
	((3,5),[[
 
		[1,1,0,0],
 
		[1,1,1,1],
 
		[1,0,0,0]
 
	]]),
 
	("3+5_",[[
 
	((3,5),[[
 
		[1,1,1],
 
		[1,0,0],
 
		[1,1,1]
 
	]]),
 
	("3+6",[[
 
	((3,6),[[
 
		[1,1,1],
 
		[0,0,0],
 
		[0,0,0]
 
	],[
 
		[1,0,0],
 
		[0,0,0],
 
		[0,0,0]
 
	],[
 
		[1,0,0],
 
		[1,0,0],
 
		[1,0,0]
 
	]]),
 
	("3+6_",[[
 
	((3,6),[[
 
		[0,0,0],
 
		[1,1,1],
 
		[1,0,0]
 
	],[
 
		[1,0,0],
 
		[1,0,0],
 
		[1,0,0]
 
	]]),
 
	("3+7",[[
 
	((3,7),[[
 
		[0,0,0,0,0],
 
		[0,0,1,1,1]
 
	],[
 
		[1,1,1,0,0],
 
		[0,0,1,0,0]
 
	]]),
 
	("3+7_",[[
 
	((3,7),[[
 
		[1,0,0],
 
		[1,1,1],
 
		[0,0,0]
 
	],[
 
		[1,0,0],
 
		[1,0,0],
 
		[1,0,0]
 
	]]),
 
	("3+8",[[
 
	((3,8),[[
 
		[1,1,1,0,0],
 
		[0,0,1,0,0]
 
	],[
 
		[0,0,0,0,0],
 
		[0,0,1,1,1]
 
	]]),
 
	("3+8_",[[
 
	((3,8),[[
 
		[0,0,0],
 
		[1,1,1],
 
		[1,0,0]
 
	],[
 
		[1,0,0],
 
		[1,0,0],
 
		[1,0,0]
 
	]]),
 
	("3+9",[[
 
	((3,9),[[
 
		[1,0,0],
 
		[1,1,1]
 
	],[
 
		[1,1,1],
 
		[0,0,0]
 
	]]),
 
	("3+9_",[[
 
	((3,9),[[
 
		[1,1,0,0],
 
		[1,0,0,0],
 
		[1,0,0,0]
 
	],[
 
		[0,1,1,1],
 
		[0,0,0,0],
 
		[0,0,0,0]
 
	]]),
 
	("3+10",[[
 
	((3,10),[[
 
		[1,1,1],
 
		[1,0,0]
 
	],[
 
		[0,0,0],
 
		[1,1,1]
 
	]]),
 
	("3+10_",[[
 
	((3,10),[[
 
		[1,1,1],
 
		[1,0,0],
 
		[0,0,0],
 
		[0,0,0]
 
	],[
 
		[0,0,0],
 
		[1,0,0],
 
		[1,0,0],
 
		[1,0,0]
 
	]]),
 
	("3+11",[[
 
	((3,11),[[
 
		[1,1,1,0],
 
		[0,0,1,0],
 
		[0,1,1,1]
 
	]]),
 
	("3+12",[[
 
	((3,12),[[
 
		[0,1,0],
 
		[1,1,0],
 
		[0,1,0]
 
	],[
 
		[0,0,0],
 
		[1,1,1],
 
		[0,0,0]
 
	]]),
 
	("3+12_",[[
 
	((3,12),[[
 
		[1,0,0],
 
		[1,0,0],
 
		[1,0,0]
 
	],[
 
		[0,0,0],
 
		[1,0,0],
 
		[0,0,0]
 
	],[
 
		[0,0,0],
 
		[1,1,1],
 
		[0,0,0]
 
	]]),
 
	("3+13",[[
 
	((3,13),[[
 
		[0,1,1,1],
 
		[0,0,0,0]
 
	],[
 
		[0,1,0,0],
 
		[1,1,1,0]
 
	]]),
 
	("3+13_",[[
 
	((3,13),[[
 
		[1,1,1],
 
		[1,0,0],
 
		[0,0,0]
 
	],[
 
		[1,0,0],
 
		[1,0,0],
 
		[1,0,0]
 
	]]),
 
	("3+14",[[
 
	((3,14),[[
 
		[0,0,0,0],
 
		[0,1,1,1]
 
	],[
 
		[1,1,1,0],
 
		[0,1,0,0]
 
	]]),
 
	("3+14_",[[
 
	((3,14),[[
 
		[1,1,0],
 
		[1,0,0],
 
		[1,0,0]
 
	],[
 
		[1,1,1],
 
		[0,0,0],
 
		[0,0,0]
 
	]]),
 
	("4+5",[[
 
	((4,5),[[
 
		[1,1,0,0],
 
		[1,0,0,0],
 
		[1,0,0,0]
 
	],[
 
		[0,1,1,1],
 
		[0,0,0,0],
 
		[0,0,0,0]
 
	]]),
 
	("4+5_",[[
 
	((4,5),[[
 
		[1,1,1],
 
		[0,0,0],
 
		[0,0,0]
 
	],[
 
		[1,0,0],
 
		[0,0,0],
 
		[0,0,0]
 
	],[
 
		[1,0,0],
 
		[1,0,0],
 
		[1,0,0]
 
	]]),
 
	("4+6",[[
 
	((4,6),[[
 
		[1,1,1,0,0],
 
		[0,0,1,0,0],
 
		[0,0,1,1,1]
 
	]]),
 
	("4+6_",[[
 
	((4,6),[[
 
		[1,1,1],
 
		[1,0,0]
 
	],[
 
		[0,0,0],
 
		[1,1,1]
 
	]]),
 
	("4+7",[[
 
	((4,7),[[
 
		[1,1,0,0],
 
		[1,1,1,1],
 
		[1,0,0,0]
 
	]]),
 
	("4+7_",[[
 
	((4,7),[[
 
		[0,0,0],
 
		[1,1,1],
 
		[1,0,0]
 
	],[
 
		[1,0,0],
 
		[1,0,0],
 
		[1,0,0]
 
	]]),
 
	("4+8",[[
 
	((4,8),[[
 
		[1,1,0,0],
 
		[1,0,0,0],
 
		[1,0,0,0]
 
	],[
 
		[0,1,1,1],
 
		[0,0,0,0],
 
		[0,0,0,0]
 
	]]),
 
	("4+9",[[
 
	((4,9),[[
 
		[1,0,0],
 
		[1,1,1],
 
		[0,0,0]
 
	],[
 
		[1,0,0],
 
		[1,0,0],
 
		[1,0,0]
 
	]]),
 
	("4+9_",[[
 
	((4,9),[[
 
		[0,1,1,1],
 
		[1,1,0,0],
 
		[1,0,0,0],
 
		[1,0,0,0]
 
	]]),
 
	("4+10",[[
 
	((4,10),[[
 
		[1,1,0],
 
		[1,0,0],
 
		[1,0,0]
 
	],[
 
		[1,1,1],
 
		[0,0,0],
 
		[0,0,0]
 
	]]),
 
	("4+10_",[[
 
	((4,10),[[
 
		[1,0,0],
 
		[1,0,0],
 
		[1,0,0]
 
	],[
 
		[0,0,0],
 
		[1,0,0],
 
		[0,0,0]
 
	],[
 
		[0,0,0],
 
		[1,1,1],
 
		[0,0,0]
 
	]]),
 
	("4+11",[[
 
	((4,11),[[
 
		[1,1,0],
 
		[1,0,0],
 
		[1,0,0]
 
	],[
 
		[1,1,1],
 
		[0,0,0],
 
		[0,0,0]
 
	]]),
 
	("4+11_",[[
 
	((4,11),[[
 
		[1,0,0],
 
		[1,0,0],
 
		[1,0,0]
 
	],[
 
		[0,0,0],
 
		[1,0,0],
 
		[0,0,0]
 
	],[
 
		[0,0,0],
 
		[1,1,1],
 
		[0,0,0]
 
	]]),
 
	("4+12",[[
 
	((4,12),[[
 
		[1,1,1,0],
 
		[0,0,1,0],
 
		[0,1,1,1]
 
	]]),
 
	("4+12_",[[
 
	((4,12),[[
 
		[1,1,1,0],
 
		[0,1,0,0]
 
	],[
 
		[0,0,0,0],
 
		[0,1,1,1]
 
	]]),
 
	("4+13",[[
 
	((4,13),[[
 
		[1,0,0,0],
 
		[1,1,0,0],
 
		[1,0,0,0]
 
	],[
 
		[0,0,0,0],
 
		[0,1,1,1],
 
		[0,0,0,0]
 
	]]),
 
	("4+14",[[
 
	((4,14),[[
 
		[1,1,1,1],
 
		[1,1,0,0],
 
		[1,0,0,0]
 
	]]),
 
	("4+14_",[[
 
	((4,14),[[
 
		[0,1,0],
 
		[1,1,0],
 
		[0,1,0]
 
	],[
 
		[0,0,0],
 
		[1,1,1],
 
		[0,0,0]
 
	]]),
 
	("5+6",[[
 
	((5,6),[[
 
		[1,1,1],
 
		[1,0,0],
 
		[0,0,0],
 
		[0,0,0]
 
	],[
 
		[0,0,0],
 
		[1,0,0],
 
		[1,0,0],
 
		[1,0,0]
 
	]]),
 
	("5+6_",[[
 
	((5,6),[[
 
		[1,0,0],
 
		[1,0,0],
 
		[1,0,0]
 
	],[
 
		[1,0,0],
 
		[0,0,0],
 
		[0,0,0]
 
	],[
 
		[1,1,1],
 
		[0,0,0],
 
		[0,0,0]
 
	]]),
 
	("5+7",[[
 
	((5,7),[[
 
		[1,1,1],
 
		[1,0,0]
 
	],[
 
		[0,0,0],
 
		[1,1,1]
 
	]]),
 
	("5+7_",[[
 
	((5,7),[[
 
		[0,0,0],
 
		[1,1,1],
 
		[1,0,0]
 
	],[
 
		[1,0,0],
 
		[1,0,0],
 
		[1,0,0]
 
	]]),
 
	("5+8",[[
 
	((5,8),[[
 
		[1,0,0],
 
		[1,1,1]
 
	],[
 
		[1,1,1],
 
		[0,0,0]
 
	]]),
 
	("5+8_",[[
 
	((5,8),[[
 
		[1,0,0],
 
		[1,1,1],
 
		[0,0,0]
 
	],[
 
		[1,0,0],
 
		[1,0,0],
 
		[1,0,0]
 
	]]),
 
	("5+9",[[
 
	((5,9),[[
 
		[1,1,1],
 
		[1,0,0],
 
		[0,0,0],
 
		[0,0,0]
 
	],[
 
		[0,0,0],
 
		[1,0,0],
 
		[1,0,0],
 
		[1,0,0]
 
	]]),
 
	("5+9_",[[
 
	((5,9),[[
 
		[0,0,1,0,0],
 
		[0,0,1,1,1]
 
	],[
 
		[1,1,1,0,0],
 
		[0,0,0,0,0]
 
	]]),
 
	("5+10",[[
 
	((5,10),[[
 
		[1,1,0,0],
 
		[1,0,0,0],
 
		[1,0,0,0]
 
	],[
 
		[0,1,1,1],
 
		[0,0,0,0],
 
		[0,0,0,0]
 
	]]),
 
	("5+10_",[[
 
	((5,10),[[
 
		[0,0,1,1,1],
 
		[0,0,1,0,0]
 
	],[
 
		[0,0,0,0,0],
 
		[1,1,1,0,0]
 
	]]),
 
	("5+11",[[
 
	((5,11),[[
 
		[1,1,1,0],
 
		[0,0,1,0],
 
		[0,1,1,1]
 
	]]),
 
	("5+11",[[
 
	((5,11),[[
 
		[1,1,1,1],
 
		[1,1,0,0],
 
		[1,0,0,0]
 
	]]),
 
	("5+12",[[
 
	((5,12),[[
 
		[1,0,0,0],
 
		[1,1,0,0],
 
		[1,0,0,0]
 
	],[
 
		[0,0,0,0],
 
		[0,1,1,1],
 
		[0,0,0,0]
 
	]]),
 
	("5+12_",[[
 
	((5,12),[[
 
		[1,0,0],
 
		[1,0,0],
 
		[1,0,0]
 
	],[
 
		[0,0,0],
 
		[1,0,0],
 
		[0,0,0]
 
	],[
 
		[0,0,0],
 
		[1,1,1],
 
		[0,0,0]
 
	]]),
 
	("5+13",[[
 
	((5,13),[[
 
		[0,1,0,0],
 
		[1,1,1,0]
 
	],[
 
		[0,1,1,1],
 
		[0,0,0,0]
 
	]]),
 
	("5+13_",[[
 
	((5,13),[[
 
		[1,1,0],
 
		[1,0,0],
 
		[1,0,0]
 
	],[
 
		[1,1,1],
 
		[0,0,0],
 
		[0,0,0]
 
	]]),
 
	("5+14",[[
 
	((5,14),[[
 
		[1,1,1,0],
 
		[0,1,0,0]
 
	],[
 
		[0,0,0,0],
 
		[0,1,1,1]
 
	]]),
 
	("5+14_",[[
 
	((5,14),[[
 
		[1,1,1],
 
		[1,0,0],
 
		[0,0,0]
 
	],[
 
		[1,0,0],
 
		[1,0,0],
 
		[1,0,0]
 
	]]),
 
	("6+7",[[
 
	((6,7),[[
 
		[1,1,1],
 
		[1,0,0],
 
		[0,0,0],
 
		[0,0,0]
 
	],[
 
		[0,0,0],
 
		[1,0,0],
 
		[1,0,0],
 
		[1,0,0]
 
	]]),
 
	("6+8",[[
 
	((6,8),[[
 
		[1,1,0,0],
 
		[1,1,1,1],
 
		[1,0,0,0]
 
	]]),
 
	("6+8_",[[
 
	((6,8),[[
 
		[1,0,0],
 
		[1,1,1],
 
		[0,0,0]
 
	],[
 
		[1,0,0],
 
		[1,0,0],
 
		[1,0,0]
 
	]]),
 
	("6+9",[[
 
	((6,9),[[
 
		[1,1,0,0],
 
		[1,1,1,1],
 
		[1,0,0,0]
 
	]]),
 
	("6+9_",[[
 
	((6,9),[[
 
		[1,1,0,0],
 
		[1,0,0,0],
 
		[1,0,0,0]
 
	],[
 
		[0,1,1,1],
 
		[0,0,0,0],
 
		[0,0,0,0]
 
	]]),
 
	("6+10",[[
 
	((6,10),[[
 
		[0,1,1,1],
 
		[1,1,0,0],
 
		[1,0,0,0],
 
		[1,0,0,0]
 
	]]),
 
	("6+10_",[[
 
	((6,10),[[
 
		[0,0,0],
 
		[1,1,1],
 
		[1,0,0]
 
	],[
 
		[1,0,0],
 
		[1,0,0],
 
		[1,0,0]
 
	]]),
 
	("6+11",[[
 
	((6,11),[[
 
		[1,1,1],
 
		[1,0,0],
 
		[0,0,0]
 
	],[
 
		[1,0,0],
 
		[1,0,0],
 
		[1,0,0]
 
	]]),
 
	("6+11_",[[
 
	((6,11),[[
 
		[1,0,0],
 
		[1,0,0],
 
		[1,0,0]
 
	],[
 
		[0,0,0],
 
		[1,0,0],
 
		[0,0,0]
 
	],[
 
		[0,0,0],
 
		[1,1,1],
 
		[0,0,0]
 
	]]),
 
	("6+12",[[
 
	((6,12),[[
 
		[1,1,1,0],
 
		[0,1,0,0],
 
		[0,1,1,1]
 
	]]),
 
	("6+12_",[[
 
	((6,12),[[
 
		[0,0,0,0],
 
		[0,1,1,1]
 
	],[
 
		[1,1,1,0],
 
		[0,1,0,0]
 
	]]),
 
	("6+13",[[
 
	((6,13),[[
 
		[1,1,1,1],
 
		[1,1,0,0],
 
		[1,0,0,0]
 
	]]),
 
	("6+13_",[[
 
	((6,13),[[
 
		[0,1,0],
 
		[1,1,0],
 
		[0,1,0]
 
	],[
 
		[0,0,0],
 
		[1,1,1],
 
		[0,0,0]
 
	]]),
 
	("6+14",[[
 
	((6,14),[[
 
		[1,0,0,0],
 
		[1,1,0,0],
 
		[1,0,0,0]
 
	],[
 
		[0,0,0,0],
 
		[0,1,1,1],
 
		[0,0,0,0]
 
	]]),
 
	("7+8",[[
 
	((7,8),[[
 
		[0,0,1,1,1],
 
		[0,0,1,0,0],
 
		[1,1,1,0,0]
 
	]]),
 
	("7+9",[[
 
	((7,9),[[
 
		[1,0,0],
 
		[1,0,0],
 
		[1,0,0]
 
	],[
 
		[1,0,0],
 
		[0,0,0],
 
		[0,0,0]
 
	],[
 
		[1,1,1],
 
		[0,0,0],
 
		[0,0,0]
 
	]]),
 
	("7+10",[[
 
	((7,10),[[
 
		[1,1,1],
 
		[1,0,0],
 
		[1,1,1]
 
	]]),
 
	("7+11",[[
 
	((7,11),[[
 
		[0,1,1,1],
 
		[0,1,0,0]
 
	],[
 
		[0,0,0,0],
 
		[1,1,1,0]
 
	]]),
 
	("7+11_",[[
 
	((7,11),[[
 
		[0,1,0],
 
		[1,1,0],
 
		[0,1,0]
 
	],[
 
		[0,0,0],
 
		[1,1,1],
 
		[0,0,0]
 
	]]),
 
	("7+12",[[
 
	((7,12),[[
 
		[1,1,1],
 
		[1,0,0],
 
		[0,0,0]
 
	],[
 
		[1,0,0],
 
		[1,0,0],
 
		[1,0,0]
 
	]]),
 
	("7+13",[[
 
	((7,13),[[
 
		[1,1,1,0],
 
		[0,1,0,0],
 
		[0,1,1,1]
 
	]]),
 
	("7+14",[[
 
	((7,14),[[
 
		[1,0,0],
 
		[1,0,0],
 
		[1,0,0]
 
	],[
 
		[0,0,0],
 
		[1,0,0],
 
		[0,0,0]
 
	],[
 
		[0,0,0],
 
		[1,1,1],
 
		[0,0,0]
 
	]]),
 
	("8+9",[[
 
	((8,9),[[
 
		[1,1,1],
 
		[1,0,0],
 
		[1,1,1]
 
	]]),
 
	("8+10",[[
 
	((8,10),[[
 
		[1,1,1],
 
		[0,0,0],
 
		[0,0,0]
 
	],[
 
		[1,0,0],
 
		[0,0,0],
 
		[0,0,0]
 
	],[
 
		[1,0,0],
 
		[1,0,0],
 
		[1,0,0]
 
	]]),
 
	("8+11",[[
 
	((8,11),[[
 
		[0,1,0,0],
 
		[0,1,1,1]
 
	],[
 
		[1,1,1,0],
 
		[0,0,0,0]
 
	]]),
 
	("8+11_",[[
 
	((8,11),[[
 
		[0,1,0],
 
		[1,1,0],
 
		[0,1,0]
 
	],[
 
		[0,0,0],
 
		[1,1,1],
 
		[0,0,0]
 
	]]),
 
	("8+12",[[
 
	((8,12),[[
 
		[1,1,0],
 
		[1,0,0],
 
		[1,0,0]
 
	],[
 
		[1,1,1],
 
		[0,0,0],
 
		[0,0,0]
 
	]]),
 
	("8+13",[[
 
	((8,13),[[
 
		[1,0,0],
 
		[1,0,0],
 
		[1,0,0]
 
	],[
 
		[0,0,0],
 
		[1,0,0],
 
		[0,0,0]
 
	],[
 
		[0,0,0],
 
		[1,1,1],
 
		[0,0,0]
 
	]]),
 
	("8+14",[[
 
	((8,14),[[
 
		[1,1,1,0],
 
		[0,1,0,0],
 
		[0,1,1,1]
 
	]]),
 
	("9+10",[[
 
	((9,10),[[
 
		[1,1,1,0,0],
 
		[0,0,1,0,0],
 
		[0,0,1,1,1]
 
	]]),
 
	("9+11",[[
 
	((9,11),[[
 
		[1,0,0,0],
 
		[1,1,0,0],
 
		[1,0,0,0]
 
	],[
 
		[0,0,0,0],
 
		[0,1,1,1],
 
		[0,0,0,0]
 
	]]),
 
	("9+11_",[[
 
	((9,11),[[
 
		[0,1,0,0],
 
		[0,1,1,1]
 
	],[
 
		[1,1,1,0],
 
		[0,0,0,0]
 
	]]),
 
	("9+12",[[
 
	((9,12),[[
 
		[1,1,1,1],
 
		[1,1,0,0],
 
		[1,0,0,0]
 
	]]),
 
	("9+12_",[[
 
	((9,12),[[
 
		[1,1,0],
 
		[1,0,0],
 
		[1,0,0]
 
	],[
 
		[1,1,1],
 
		[0,0,0],
 
		[0,0,0]
 
	]]),
 
	("9+13",[[
 
	((9,13),[[
 
		[1,1,1,0],
 
		[0,1,0,0],
 
		[0,1,1,1]
 
	]]),
 
	("9+14",[[
 
	((9,14),[[
 
		[1,0,0],
 
		[1,0,0],
 
		[1,0,0]
 
	],[
 
		[0,0,0],
 
		[1,0,0],
 
		[0,0,0]
 
	],[
 
		[0,0,0],
 
		[1,1,1],
 
		[0,0,0]
 
	]]),
 
	("10+11",[[
 
	((10,11),[[
 
		[1,0,0,0],
 
		[1,1,0,0],
 
		[1,0,0,0]
 
	],[
 
		[0,0,0,0],
 
		[0,1,1,1],
 
		[0,0,0,0]
 
	]]),
 
	("10+11_",[[
 
	((10,11),[[
 
		[0,1,0,0],
 
		[1,1,1,0]
 
	],[
 
		[0,1,1,1],
 
		[0,0,0,0]
 
	]]),
 
	("10+12",[[
 
	((10,12),[[
 
		[1,1,1,1],
 
		[1,1,0,0],
 
		[1,0,0,0]
 
	]]),
 
	("10+12_",[[
 
	((10,12),[[
 
		[1,1,1],
 
		[1,0,0],
 
		[0,0,0]
 
	],[
 
		[1,0,0],
 
		[1,0,0],
 
		[1,0,0]
 
	]]),
 
	("10+13",[[
 
	((10,13),[[
 
		[1,0,0],
 
		[1,0,0],
 
		[1,0,0]
 
	],[
 
		[0,0,0],
 
		[1,0,0],
 
		[0,0,0]
 
	],[
 
		[0,0,0],
 
		[1,1,1],
 
		[0,0,0]
 
	]]),
 
	("10+14",[[
 
	((10,14),[[
 
		[1,1,1,0],
 
		[0,1,0,0],
 
		[0,1,1,1]
 
	]]),
 
	("11+12",[[
 
	((11,12),[[
 
		[1,0,0],
 
		[1,1,0],
 
		[1,0,0]
 
	],[
 
		[0,0,0],
 
		[1,1,1],
 
		[0,0,0]
 
	]]),
 
	("11+12_",[[
 
	((11,12),[[
 
		[0,0,0],
 
		[1,1,1],
 
		[0,0,0]
 
	],[
 
		[0,0,0],
 
		[0,1,0],
 
		[0,0,0]
 
	],[
 
		[0,1,0],
 
		[0,1,0],
 
		[0,1,0]
 
	]]),
 
	("11+13",[[
 
	((11,13),[[
 
		[1,0,0],
 
		[1,1,0],
 
		[1,0,0]
 
	],[
 
		[0,0,0],
 
		[1,1,1],
 
		[0,0,0]
 
	]]),
 
	("11+13_",[[
 
	((11,13),[[
 
		[1,1,1],
 
		[0,1,0]
 
	],[
 
		[0,0,0],
 
		[1,1,1]
 
	]]),
 
	("11+14",[[
 
	((11,14),[[
 
		[1,0,0],
 
		[1,1,0],
 
		[1,0,0]
 
	],[
 
		[0,0,0],
 
		[1,1,1],
 
		[0,0,0]
 
	]]),
 
	("11+14_",[[
 
	((11,14),[[
 
		[1,1,1],
 
		[0,1,0]
 
	],[
 
		[0,0,0],
 
		[1,1,1]
 
	]]),
 
	("12+13",[[
 
	((12,13),[[
 
		[1,0,0],
 
		[1,1,0],
 
		[1,0,0]
 
	],[
 
		[0,0,0],
 
		[1,1,1],
 
		[0,0,0]
 
	]]),
 
	("12+14",[[
 
	((12,14),[[
 
		[1,0,0],
 
		[1,1,0],
 
		[1,0,0]
 
	],[
 
		[0,0,0],
 
		[1,1,1],
 
		[0,0,0]
 
	]]),
 
	("13+14",[[
 
	((13,14),[[
 
		[1,0,1],
 
		[1,1,1],
 
		[1,0,1]
 
	]])
 
]
 
\ No newline at end of file
tetris.py
Show inline comments
 
from datetime import datetime
 

	
 
import numpy as np
 

	
 
from pieces import listRotations,listShifts,fits
 
from dlx import Header,Column,Cell
 
import piece_list
 

	
 

	
 
board=np.zeros((1,4,3))
 
boat=np.array([[[0,1,0],[1,1,1]]])
 
sz=np.array([[[1,1,0],[0,1,1]]])
 
el=np.array([[[1,1,1],[1,0,0]]])
 
board=np.zeros((2,5,5))
 
board[0][2][2]=1
 

	
 
(nz,ny,nx)=board.shape
 
pieces=[("el1",el),("el2",el),("sz",sz)]
 
header=[name for (name,p) in pieces]+\
 
pieces=[(name,np.array(arr)) for (name,arr) in piece_list.pieces]
 
header=list(range(1,15))+\
 
	[(z,y,x) for z in range(nz) for y in range(ny) for x in range(nx) if not board[z][y][x]]
 
index={label:i for (i,label) in enumerate(header)}
 

	
 
matrix=[]
 

	
 
for (name,piece) in pieces:
 
for ((nameA,nameB),piece) in pieces:
 
	for p in listRotations(piece):
 
		for shift in listShifts(board,p):
 
			fit=fits(board,p,shift)
 
			if fit is not False:
 
				row=[0]*len(header)
 
				row[index[name]]=1
 
				row[index[nameA]]=1
 
				row[index[nameB]]=1
 
				for coords in fit: row[index[coords]]=1
 
				matrix.append(row)
 

	
 
print(header)
 
for row in matrix: print(row)
 
print(len(header),"cols")
 
print(len(matrix),"rows")
 

	
 
columns=[]
 
head=Header()
 
for label in header:
 
	c=Column(label)
 
	c.attachRight(head)
 
@@ -45,7 +47,9 @@ for row in matrix:
 
		c.attachDown(col)
 
		cells.append(c)
 
		c.attachRight(cells[0])
 
		col.size+=1
 

	
 
print()
 
print(datetime.now())
 
head.search()
 
print(datetime.now())
0 comments (0 inline, 0 general)