Beispiel #1
0
 def generate(self):
   gencounter = 0; expected = 1634688
   for wpattern in self.wpattern_list:
     array = [int(c) for c in wpattern]
     workSetList = zip(self.tilr.tilrsets, array)
     # print 'workSetList', workSetList 
     sc = SetsCombiner()
     for workSet in workSetList:
       n_elems_in_the_slots = workSet[1]
       if n_elems_in_the_slots == 0:
         continue
       sc.addSetWithQuantities(workSet)
     for self.combined in sc.next_combination():
       gencounter+=1
       self.save(self.combined)
       # print gencounter, self.combined
   print 'gencounter', gencounter, 'expected', expected 
def generate(wpattern):
  global all_generated
  pattern_list = map(int, wpattern)
  print wpattern, pattern_list
  # dozens_thru_slots = map(tilr.get_dozens_in_slot_n, xrange(n_slots))
  # print 'dozens_thru_slots', dozens_thru_slots
  combiner = SetsCombiner()
  for slot_n in xrange(n_slots):
    quantity = pattern_list[slot_n]
    if quantity == 0:
      continue 
    dozens = tilr.get_dozens_in_slot_n(slot_n)
    workSetWithQuantity = (dozens, quantity) 
    print 'Adding workSetWithQuantity', workSetWithQuantity
    combiner.addSetWithQuantities(workSetWithQuantity)
  total_combinations = combiner.get_total_combinations()
  all_generated += total_combinations
  print 'total_combinations', total_combinations
  # sys.exit(0) 
  for i, jogo in enumerate(combiner.next_combination()):
    jogo.sort()
    print all_generated, i, 'combining', convert_intlist_to_spaced_zfillstr(jogo)
Beispiel #3
0
def adhoc_test2():
  sc = SetsCombiner()
  sc.addSetWithQuantities(([1,2,3],2))
  sc.addSetWithQuantities(([4,5,6],2))
  sc.combineSets()
  print sc.getAllCombinationsAfterCombine()