def analyze(): patternDistance = PatternDistanceAnalyzer() START_AT_N_CONC = 5 slider = ConcursoExt() last_concurso = slider.get_last_concurso() repeats_dict = Dict2() for nDoConc in range(START_AT_N_CONC, last_concurso.nDoConc+1): concurso = slider.get_concurso_by_nDoConc(nDoConc) contrajogos_as_dezenas_list = last_concurso.get_contrajogos_as_dezenas_list_down_to_depth(depth=4, inclusive=True) if contrajogos_as_dezenas_list == None: continue #print concurso.nDoConc, concurso.date, concurso.get_dezenas(), contrajogos_as_dezenas_list repeats_array = jogos_functions.get_array_n_repeats_with_m_previous_games(concurso.get_dezenas(), contrajogos_as_dezenas_list) token = ''.join(map(str, repeats_array)) patternDistance.add_pattern(token) repeats_dict.add1_or_set1_to_key(token) tokens_and_quants = repeats_dict.items() tokens_and_quants.sort(key = lambda x : x[1]) tokens_and_quants.reverse() for token_and_quant in tokens_and_quants: token = token_and_quant[0] quant = token_and_quant[1] pattern = rightFillToNSpaces(token, 3) zquant = leftFillToNSpaces(str(quant), 3) print pattern, ':', zquant patternDistance.mount_distances_histogram() patternDistance.summarize() analyze()
def filter_in_those_within_n_repeats_with_m_previous_games(jogo_as_dezenas, contrajogos, compare_repeat_list): ''' Suppose the following "small" game history: ( 1, 2, 3, 4, 5, 6) ( 7, 8, 9,10,11,12) (13,14,15,16,17,18) Now we ask how many repeats there are for the game: ( 1, 7,13,19,25,26) One can see that 1, 7 and 13 happened in the "small" game history above, so there are 3 repeats Because these repeats are single, ie, they do not repeat more times in history, the repeat information comes in positional, ie, it's [3], 3 inside a list. The second element in such a list informs that its value should be applied for a double repeat. Example: [3, 1] means: allow up to 3 single repeats and 1 double repeat (a double repeat is a dozen that happens twice in the game history considered, ie, through contrajogos). Double repeats are not contemplated here because the coincides_history filter above encompasses ''' repeats_array = jogos_functions.get_array_n_repeats_with_m_previous_games(jogo_as_dezenas, contrajogos) # repeats_array is not planned to return as None, but it can be returned empty if len(repeats_array) == 0: return False bool_array_result = map(swlambda.is_equal, repeats_array, compare_repeat_list) if False in bool_array_result: return False # This means: all elements in bool_array_result are True, jogo_as_dezenas passed the filter return True '''