def parsePuzzle(self, filename): start = time() puzzle = PuzzleFactory.createFutoshikiPuzzle(7) # Set the initial data to work with myFile = open("./futoshiki.txt") values = range(1,10) stringArray = myFile.readlines() y = 0 addingValues = True for line in stringArray: if line.startswith("relativity"): addingValues = False if addingValues: x = 0 for el in line.split(' '): try: if(int(el) in values): puzzle.grid.setConstraintGridValue(x,y,int(el)) except ValueError: pass x += 1 y += 1 else: cellStrings = line.split(">") if len(cellStrings) == 2: c1, c2 = cellStrings x,y = c1.split(",") x = int(x) y = int(y) cell1 = puzzle.grid.getCellFromSquareGrid(x-1,y-1) x,y = c2.split(",") x = int(x) y = int(y) cell2 = puzzle.grid.getCellFromSquareGrid(x-1,y-1) cg = puzzle.addConstraintGroup("Relativity") constraint = cg.addConstraint(CellGreaterThanCellConstraint) cg.addCell(cell1) cg.addCell(cell2) constraint.setLesserCell(cell1) constraint.setGreaterCell(cell2) # And solve solver = Solver(puzzle) #print solver #grid.printAsSudoku() #print "Done in", int((time() - start) *1000), "ms" return puzzle, solver