This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| def compute(cipher): | |
| possiblecodes = [] | |
| for x in range(97,123): | |
| for y in range(97, 123): | |
| for z in range(97,123): | |
| password = chr(x) + chr(y) + chr(z) | |
| count = 0 | |
| decrypt = [] | |
| for i in cipher: | |
| temp = i^(ord(password[count % 3])) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| def compute(): | |
| count = [] | |
| for n in range(1,10): | |
| for i in range(1,22): | |
| if i == len(str(n**i)): | |
| count.append(n**i) | |
| return len(count) | |
| #Used the following function to find the bounds for n | |
| #n = 9 bound is 22 because 9^22 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| def compute(limit): | |
| f = [int(4*(x**2)+1) for x in range(limit+1)] #Initialise the list f | |
| max_prime_factor = [0]*(limit+1) #Initialise the list max_prime_factor | |
| for x in range(1,len(f)): #Go through f | |
| div = f[x] #Initialise divisor | |
| if div > 1: #Check if divisor > 1 | |
| curr1 = x % div | |
| while curr1 <= limit: #while curr = x + k*f[x] < limit we continue | |
| if f[curr1] % div == 0: #Check if f[x+k*f[x]] is divisible by f[x] | |
| max_prime_factor[curr1] = max(max_prime_factor[curr1], div) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| def compute(): | |
| eulercoins = [1504170715041707] | |
| current_eulercoin = 1504170715041707 | |
| inv = pow(1504170715041707, -1, 4503599627370517) | |
| n = 2 | |
| while True: | |
| number = 1504170715041707*n % 4503599627370517 #Search downwards | |
| if number < current_eulercoin: | |
| current_eulercoin = number | |
| eulercoins.append(number) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| def A(k,n): | |
| total = 0 | |
| f0 = 1 | |
| modulo = 1000000007 | |
| power = pow(2, n//k, modulo) | |
| for a in range(0, n//k + 1): | |
| total = (total + (f0 * pow(power, k-2*a, modulo))) % modulo | |
| f0 = (f0*(k-2*a)*(k-2*a-1)) % modulo | |
| f0 = (f0*pow((a+1)**2, -1, modulo)) % modulo | |
| return total |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| def compute(): | |
| matrix = [[131, 673, 234, 103,18], | |
| [201, 96, 342, 965, 150], | |
| [630, 803, 746, 422, 111], | |
| [537, 699, 497, 121, 956], | |
| [805, 732, 524, 37, 331]] | |
| rows = len(matrix) #Number of rows | |
| columns = len(matrix[0])#Number of columns | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| def compute(limit): | |
| d = [1] + [0] * limit | |
| primes = eulerlib.primes(limit) | |
| mod = 10**9 | |
| Fibonnaci_numbers = [2,3,5,8,13,21,34,55,89,144,233,377,610,987,1597,2584,4181,6765,10946,17711,28657,46368] | |
| for p in primes: | |
| for i in range(p,limit+1): | |
| d[i] += (p*d[i-p] % mod) | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| def is_cyclic(x,y): | |
| if (x % 100) == int(str(y // 100)): | |
| return True | |
| return False | |
| def compute(): | |
| tri = [(int(x*(x + 1)/2), "triangle") for x in range(1,1000) if 999 < x*(x + 1)/2 < 10000] | |
| sq = [(int(x*(x)), "square") for x in range(1,1000) if 999 < x*(x) < 10000] | |
| pen = [(int(x*(3*x - 1)/2), "pentagonal") for x in range(1,1000) if 999 < x*(3*x - 1)/2 < 10000] | |
| hexa = [(int(x*(2*x - 1)), "hexagonal") for x in range(1,1000) if 999 < (x*(2*x - 1)) < 10000] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| def PentagonalNumberTheorem(N): | |
| p = [1] + [0]*(N + 1) #Initalise array | |
| for n in range(1,len(p)): | |
| y = 1 | |
| while True: | |
| if y % 2 == 0: #Find sign | |
| sign = -1 | |
| else: | |
| sign = 1 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| def dicecomb(): #Produces all dice combinations, there are 10 C 6 = 210 | |
| dicecombs = set() | |
| for a in range(0,10): | |
| for b in range(0,9): | |
| for c in range(0,8): | |
| for d in range(0,7): | |
| for e in range(0,6): | |
| for f in range(0,5): | |
| if len(set([a,b,c,d,e,f])) == 6: | |
| dicecombs.add(tuple(sorted((a,b,c,d,e,f)))) |