[ create a new paste ] login | about

morgkl6

Name:
Email:
Site/Blog:
Location:
Default language:
Favorite languages:
About:

Saved pastes by morgkl6:

Python, pasted on Jan 20:
1
2
3
4
5
def subStringMatchExact(target, key):  # Iterative function that prints the location(s) of a key string in a target string as a tuple.
	isFound = True                              
	location = 0                                     # Initial starting point (first item of target string)
	x = 0                                                  # x is the location where key is found in target
	listOfLocations = []                         # list of locations found
...
view (17 lines, 1 line of output)
Python, pasted on Jan 20:
1
2
3
4
5
def subStringMatchExact(target, key):  # Iterative function that prints the location(s) of a key string in a target string as a tuple.
	isFound = True                              
	location = 0                                     # Initial starting point (first item of target string)
	x = 0                                                  # x is the location where key is found in target
	listOfLocations = []                         # list of locations found
...
view (17 lines)
Python, pasted on Jan 20:
1
2
3
4
def count_letters(s):
    if s == '':
        return 0
    return 1 + count_letters(s[1:])
...
view (9 lines, 1 line of output)
Python, pasted on Jan 18:
1
2
def countSubStringMatchRecursive(target, key, count = 0): #Recursive function that counts instances of key in target
                                              # by modifying the target string to include only the letters
...
view (17 lines, 1 line of output)
Python, pasted on Jan 18:
1
2
3
4
5
keys_in_target = []



def countSubStringMatchRecursive(target, key): #Recursive function that counts instances of key in target
...
view (18 lines, 1 line of output)
Python, pasted on Jan 18:
1
2
3
4
5
def count_sub_string_match(target, key): # finds location of key in target.
                                                                 # Input is target string, key string and starting
                                                                 # position on target string
    count = 0
    location = 0
...
view (14 lines, 1 line of output)
Python, pasted on Jan 17:
1
2
3
4
5
#PS2, Q4
#iterative function that increases the value of total_mcnuggets tested in the nested "mcnuggets" function (which determine if the number is solvable by the Diophantine equation). The nested "mcnuggets" function is run (with increasing the input by 1 each time) until x numbers have been added to the "solvable" list (where x is equal to the number of mcnuggets in the smallest package).  Once x numbers have been added to the "solvable" list, the differences between the last numbers added to the solvable list are. If each difference is 1 (i.e. all the numbers are consecutive), then this is the solution and the last number added to the "unsolvable" list is printed. If not all the differences are one, the input increases by 1 and the function starts over.

solvable = [0]
unsolvable = []
...
view (43 lines, 1 line of output)
Python, pasted on Jan 15:
1
2
3
4
5
count = 2
x = 4
while count < 1000:
    for p in range(2, x):
        if x % p == 0:
...
view (11 lines, 998 lines of output)
Python, pasted on Jan 13:
1
2
3
4
5
# 01/13/2012
# PS2,Q3: Program to calculate the highest number of mcnuggets that cannot be bought by packs of 6, 9 and 20
# contributor: morgkl6

solvable = [0] #list for number of mcnuggets that are evenly divisible
...
view (38 lines, 1 line of output)
Python, pasted on Jan 12:
1
2
3
4
5
def mcnuggets(total_mcnuggets):
	solution_found = False
	for num6packs in range(0, total_mcnuggets/6+1):
		for num9packs in range(0, (total_mcnuggets - 6*num6packs)/9+1):
			num20packs = (total_mcnuggets - 9*num9packs - 6*num6packs)/20
...
view (11 lines, 5 lines of output)