@@ -594,20 +594,20 @@ def __getitem__(self, i):
594594 )):
595595 wip_perm_sequence_dict [j ] = unused_value
596596
597- candidate_sub_perm_space_length = \
597+ candidate_sub_perm_space = \
598598 PermSpace ._create_with_cut_prefix (
599599 self .sequence ,
600600 n_elements = self .n_elements ,
601601 fixed_map = wip_perm_sequence_dict ,
602602 is_combination = self .is_combination ,
603603 shit_set = shit_set
604- ). length
604+ )
605605
606- if wip_i < candidate_sub_perm_space_length :
606+ if wip_i < candidate_sub_perm_space . length :
607607 available_values .remove (unused_value )
608608 break
609609 else :
610- wip_i -= candidate_sub_perm_space_length
610+ wip_i -= candidate_sub_perm_space . length
611611 if self .is_combination :
612612 shit_set .add (wip_perm_sequence_dict [j ])
613613 del wip_perm_sequence_dict [j ]
@@ -779,37 +779,16 @@ def index(self, perm):
779779 )
780780 temp_fixed_map .update (self .fixed_map )
781781
782+ candidate_sub_perm_space = \
783+ PermSpace ._create_with_cut_prefix (
784+ self .sequence ,
785+ n_elements = self .n_elements ,
786+ fixed_map = temp_fixed_map ,
787+ is_combination = self .is_combination ,
788+ shit_set = shit_set
789+ )
782790
783- head = []
784- n_elements_to_use = self .n_elements
785- for k in sequence_tools .CuteRange (infinity ):
786- try :
787- head .append (temp_fixed_map [k ])
788- except KeyError :
789- break
790- else :
791- del temp_fixed_map [k ]
792- n_elements_to_use -= 1
793- sequence_to_use = list (self .sequence )
794- for item in head :
795- if self .is_combination :
796- sequence_to_use = sequence_to_use [
797- sequence_to_use .index (item ) + 1 :
798- ]
799- else :
800- sequence_to_use .remove (item )
801-
802- sequence_to_use = [x for x in sequence_to_use if x not in shit_set ]
803-
804- temp_fixed_map = {key - len (head ): value for key , value in temp_fixed_map .items ()}
805-
806- if len (sequence_to_use ) >= n_elements_to_use :
807- wip_perm_number += PermSpace (
808- sequence_to_use ,
809- fixed_map = temp_fixed_map ,
810- n_elements = n_elements_to_use ,
811- is_combination = self .is_combination
812- ).length
791+ wip_perm_number += candidate_sub_perm_space .length
813792 if self .is_combination :
814793 shit_set .add (lower_value )
815794
0 commit comments