Ejemplo n.º 1
0
def pattern_023():
    # Simple pattern generation using division and string matching.

    source_numbers = [
        53, 279, 505, 731, 957, 1183, 1409, 1635, 1861, 2087, 2313, 2539, 2765,
        2991, 3217, 3443, 3669, 3895, 4121, 4347, 4573, 4799, 5025, 5251, 5477,
        5703, 5929, 6155, 6381, 6607, 6833, 7059, 7285, 7511, 7737, 7963, 8189,
        8415, 8641, 8867, 9093, 9319, 9545, 9771, 9997
    ]
    display_char = '.'
    another_set = []

    for i in source_numbers:
        another_set.append(math.sqrt(i) * 1.81)

    # Chart setup and display
    _common.chart_setup(plt)
    plt.xlabel('source numbers, N')
    plt.ylabel('Sq Root of N * 1.81')
    plt.scatter(source_numbers, another_set, marker=display_char)
    plt.title(_common.function_name(), fontsize=14)
    plt.savefig( _common.PATH_TO_PLOTS + \
        _common.function_name() + \
        '.png')
    plt.show()
    plt.clf()
Ejemplo n.º 2
0
def pattern_013():
    # Simple pattern generation using division and string matching.

    # Parameters
    pattern_match = 9
    number_generator = math.e
    range_start = 1
    range_end = 10000
    display_char = '.'

    # Lists for each axis
    list_of_candidates = []
    list_of_numbers = []

    # # Looping logic and string building
    for i in range(range_start, range_end):
        candidate = Decimal(i / number_generator) % 1
        if str(candidate).find(str(pattern_match)) > -1:
            list_of_candidates.append(candidate)
            list_of_numbers.append(i)

    # Chart setup and display
    _common.chart_setup(plt)
    plt.xlabel('Occurances of ' + str(pattern_match) + " within N÷" +
               str(round(number_generator, 2)))
    plt.ylabel('Range of N')
    plt.scatter(list_of_candidates, list_of_numbers, marker=display_char)
    plt.title(_common.function_name(), fontsize=14)
    plt.savefig( _common.PATH_TO_PLOTS + \
        _common.function_name() + \
        '-' + str(pattern_match) + \
        '-' + str(round(number_generator, 2)) + \
        '.png')
    plt.show()
    plt.clf()
def pattern_021_generator():
# Simple pattern generation using division and string matching.

	for j in range(0,1000):

		# Parameters
		pattern_match = 13579
		number_generator = 1.0 + j/1000
		range_start = 1
		range_end = 10000
		display_char = '.'

		# Lists for each axis
		list_of_candidates = []
		list_of_numbers = []

		# # Looping logic and string building
		for i in range(range_start, range_end):
			candidate = Decimal(i/number_generator) % 1
			if str(candidate).find( str(pattern_match) ) > -1:
				list_of_candidates.append( candidate )
				list_of_numbers.append( i )
				print( str(i) + ' / ' + str(candidate) )

		# Chart setup and display
		if len(list_of_candidates) > 0: # don't plot if no values
			_common.chart_setup(plt)
			plt.xlabel('Occurances of ' + \
						str(pattern_match) + \
						" within N÷" + \
						str(round(number_generator, 2)) )
			plt.ylabel('Range of N')
			plt.scatter(list_of_candidates, list_of_numbers, marker=display_char)
			plt.title(_common.function_name(), fontsize=14)
			plt.savefig( _common.PATH_TO_PLOTS + \
						 _common.function_name() + \
						 '-' + str(pattern_match) + \
						 '-' + str(round(number_generator, 3)) + \
						 '-' + str(j) + \
						 '.png')
			# plt.show() # commented out, otherwise you will need to manually dismiss each new plot
			plt.clf()