# now, try from the right to the left. mark_group_i = len(row) for i, group in list(enumerate(groups))[-1::-1]: if i in used_groups: continue group_type = types[i] if group_type == self.NULL: # if the type is self.NULL quit trying. break elif group_type == self.MARK: mark_group_i -= 1 if mark_group_i >= 0 and row[mark_group_i] == group: indices.add(mark_group_i) return indices if __name__ == '__main__': if len(sys.argv) == 1: reader = Reader("levels/lambda.krk") else: reader = Reader(sys.argv[1]) _level = reader.get_level() puzzle = KRPuzzle(_level) puzzle.start()
for i, _file in enumerate(categories): print " " + str(i + 1) + ".", _file print category = -1 while category < 0 or category > len(categories): category = int(raw_input("Enter the category number: ")) if category != 0: category -= 1 category_dir = join(DIRECTORY, categories[category]) if len(sys.argv) > 1: _id = sys.argv[1] random_puzzle =_id + ".krk" else: cat_files = [f for f in listdir(category_dir) if isfile(join(category_dir, f))] random_puzzle = choice(cat_files) reader = Reader(join(category_dir, random_puzzle)) puzzle = KRPuzzle(reader.get_level()) try: puzzle.start() except Exception as e: print e.message puzzle.end() # puzzle.output()