Oct-28-2020, 12:39 PM
I have this function, it prints a list of values.
I also have functions that will find the greatest common divisor of all numbers in a list
def kasinski(text): trigraphs=[] distances=[] for trigraph in range (len(text)-2): newtrigraph= text[trigraph:trigraph+3] if newtrigraph in trigraphs: distances.append(trigraph-(text.index(newtrigraph))) else: trigraphs.append(newtrigraph) trigraphs.append(trigraph) return distances
I also have functions that will find the greatest common divisor of all numbers in a list
def gcd(x,y): if y==0: return x else: return gcd(y, x% y) def gcd_list_helper(list, index: if index==len((list)-1): return list[index] else: return gcd(list[index], gcd_list_helper(list, index+1)) def gcd_of_list(list): return gcd_list_helper(list, 0)I am having trouble integrating the gcd function into my first function so that the kasiski function returns the GCD of the list rather than the list. Any pointers?