@@ -239,7 +239,7 @@ def sol(n):
239239
240240 def gen (self , target_num_instances ):
241241 for n in [7824 ] + list (range (target_num_instances )):
242- if len ( self .instances ) == target_num_instances :
242+ if self .num_generated_so_far ( ) == target_num_instances :
243243 return
244244 self .add (dict (n = n ), test = n <= 100 )
245245
@@ -410,7 +410,7 @@ def mirror(coords): # rotate to all four corners
410410 def gen (self , target_num_instances ):
411411 for easy in range (47 ):
412412 for side in range (47 ):
413- if len ( self .instances ) == target_num_instances :
413+ if self .num_generated_so_far ( ) == target_num_instances :
414414 return
415415 test = side < 5 or side == 10
416416 num_points = 1 if side == 1 else 2 * side
@@ -556,7 +556,6 @@ def print_sets(sets):
556556 if i == 2 or i == 5 :
557557 ans += "\n "
558558
559-
560559 @staticmethod
561560 def gen_sudoku_puzzle (rand ):
562561
@@ -640,14 +639,14 @@ def solve_helper():
640639 done = False
641640 while not done :
642641 done = True
643- pi = list ([i for i in range (81 ) if x [i ]!= "_" ])
642+ pi = list ([i for i in range (81 ) if x [i ] != "_" ])
644643 rand .shuffle (pi )
645644 for i in pi :
646645 old = x [i ]
647646 x [i ] = "_"
648647 ans = solve ("" .join (x ))
649648 assert ans
650- if len (ans )> 1 :
649+ if len (ans ) > 1 :
651650 x [i ] = old
652651 else :
653652 done = False
@@ -657,11 +656,10 @@ def solve_helper():
657656
658657 return "" .join (x )
659658
660-
661659 def gen_random (self ):
662660
663661 puz = None
664- for attempt in range (10 if len ( self .instances ) < 10 else 1 ):
662+ for attempt in range (10 if self .num_generated_so_far () < 10 else 1 ):
665663 puz2 = Sudoku .gen_sudoku_puzzle (self .random )
666664 if puz is None or puz2 .count ("_" ) > puz .count ("_" ):
667665 puz = puz2
@@ -698,8 +696,7 @@ def sol():
698696
699697
700698class NecklaceSplit (PuzzleGenerator ):
701- """[Necklace Splitting Problem](https://en.wikipedia.org/wiki/Necklace_splitting_problem)
702- """
699+ """[Necklace Splitting Problem](https://en.wikipedia.org/wiki/Necklace_splitting_problem)"""
703700
704701 @staticmethod
705702 def sat (n : int , lace = "bbrbrbbbbbbrrrrrrrbrrrrbbbrbrrbbbrbrrrbrrbrrbrbbrrrrrbrbbbrrrbbbrbbrbbbrbrbb" ):
0 commit comments