def __init__(self, N_DEZENAS_NO_VOLANTE=60, N_DEZENAS_NO_SORTEIO=6): self.N_DEZENAS_NO_VOLANTE = N_DEZENAS_NO_VOLANTE self.N_DEZENAS_NO_SORTEIO = N_DEZENAS_NO_SORTEIO self.lgiCombiner = IndicesCombiner(self.N_DEZENAS_NO_VOLANTE-1, self.N_DEZENAS_NO_SORTEIO, False) self.session_index = 0 self.current_dezenas_list = self.lgiCombiner.current()
class GeradorIterator(object): def __init__(self, N_DEZENAS_NO_VOLANTE=60, N_DEZENAS_NO_SORTEIO=6): self.N_DEZENAS_NO_VOLANTE = N_DEZENAS_NO_VOLANTE self.N_DEZENAS_NO_SORTEIO = N_DEZENAS_NO_SORTEIO self.lgiCombiner = IndicesCombiner(self.N_DEZENAS_NO_VOLANTE-1, self.N_DEZENAS_NO_SORTEIO, False) self.session_index = 0 self.current_dezenas_list = self.lgiCombiner.current() def restart(self): self.lgiCombiner.parkBeforeFirst() indices = self.lgiCombiner.current() self.current_dezenas_list = map(addOneToEachElement, indices) def move_to_element_by_its_indices(self, indices_position_to_move_at): self.lgiCombiner.move_to_position_by_iArray(indices_position_to_move_at) indices = self.lgiCombiner.current() self.current_dezenas_list = map(addOneToEachElement, indices) # print 'current_dezenas_list', self.current_dezenas_list def move_to_last(self): indices = self.lgiCombiner.moveToLastOne() self.current_dezenas_list = map(addOneToEachElement, indices) def move_to_one_before_last(self): self.lgiCombiner.move_to_one_before_last() indices = self.lgiCombiner.current() self.current_dezenas_list = map(addOneToEachElement, indices) def __iter__(self): return self.get_current() def next(self): self.produce_next() if self.current_dezenas_list != None: return copy.copy(self.current_dezenas_list) # self.current_dezenas_list[:] else: raise StopIteration, 'End of Iteration' # return None def get_index(self): # to implement using the lgi's technique pass def produce_next(self): indices = self.lgiCombiner.next() if indices != None: self.session_index += 1 self.current_dezenas_list = map(addOneToEachElement, indices) else: self.current_dezenas_list = None def get_current(self): if self.current_dezenas_list != None: return self.current_dezenas_list[:] return None def __str__(self): outlist = self.get_current() if outlist != None: return convert_intlist_to_spaced_zfillstr(outlist) return '<None>'