[Puzzler-users] pentomino rings
Brought to you by:
goodger
From: Alexandre M. <mu...@xp...> - 2013-05-24 18:32:58
|
Here's my code for handling pentomino cylinders of various dimensions: def getPentominoesLoopByHeight(h): class PentominoesLoopByHeight(PentominoesLoop): height = h width = 60 / h return PentominoesLoopByHeight class PentominoesLoop(Pentominoes): """ Symmetry: restrict V to one x position and one orientation. """ check_for_duplicates = True def build_matrix(self): keys = sorted(self.pieces.keys()) x_coords, x_aspect = self.pieces['V'][0] for y in range(self.height - 2): translated = x_aspect.translate((0, y)) self.build_matrix_row('V', translated) keys.remove('V') for key in keys: for coords, aspect in self.pieces[key]: for x in range(self.width): for y in range(self.height - aspect.bounds[1]): translated = aspect.translate((x, y), (self.width, 0)) self.build_matrix_row(key, translated) Results: 4×15: 901 solutions, 418,086 searches, duration 0:00:45.155573 5×12: 8,272 solutions, 2,845,928 searches, duration 0:04:55.194066 6×10: 28,996 solutions, 9,388,188 searches, duration 0:15:45.094640 That's running Puzzler in pypy, which is a little less than three times as fast as python 2.7.3 on this for me. I'm running the 10×6 now, but it might take a while. AOM |