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 sum_digits_mod(x): | |
| facts = [1, 1, 2, 6, 24, 120, 720, 5040, 40320, 362880] | |
| totalsum = 0 | |
| while x != 0: | |
| totalsum += facts[x % 10] | |
| x = x // 10 | |
| return totalsum | |
| def compute(): | |
| overalltotal = 0 |
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(): | |
| checker = ['1', '2', '3', '4', '5', '6', '7', '8', '9'] | |
| concatenated_product_list = [] | |
| for z in range(2,10): | |
| for x in range(1,10**math.floor(9/z)): | |
| temp_str = "" | |
| for y in range(1,z+1): | |
| product = x*y | |
| temp_str += str(product) | |
| if sorted(temp_str) == checker: |
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
| Triangle_number = [ "the triangle numbers from the txt file" ] | |
| def sumofname(x): | |
| namesum = 0 | |
| for i in range(len(words[x])): | |
| namesum += ord(words[x][i])-64 | |
| return namesum | |
| def compute(): | |
| count = 0 |
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_pentagonal(x): | |
| #Take the inverse function to test whether or not a number is pentagonal | |
| if (1+(24*x+1)**0.5) % 6 == 0: | |
| return True | |
| return False | |
| def compute(): | |
| k = 1 | |
| while True: | |
| for j in range(1,k): # this ensures that a > b therefore a-b is minimised |
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_pentagonal(x): | |
| #Take the inverse function to test whether or not a number is pentagonal | |
| if (1+(24*x+1)**0.5) % 6 == 0: | |
| return True | |
| return False | |
| def is_hexagonal(x): | |
| #Take the inverse function to test whether or not a number is hexagonal | |
| if (1+(8*x+1)**0.5) % 4 == 0: | |
| return True |
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 all_numbers(alist): | |
| nums = set() | |
| for x in alist: | |
| for y in x: | |
| nums.add(y) | |
| return list(nums) | |
| def method1(): | |
| possible_numbers = (all_numbers(keys)) | |
| possible_passcode = list(itertools.permutations(possible_numbers)) |
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 goldbachs(number): | |
| for x in range(1, int(math.sqrt(number))+1): | |
| temp_var = number - 2*(x**2) | |
| if is_prime(temp_var) == True: | |
| return True | |
| return False | |
| def compute(): | |
| count = 33 | |
| while True: |
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 list_primality_modified(n): | |
| result = [0] * (n + 1) #Initialize an array of length n+1 | |
| for i in range(2,int((n)) + 1): #We want to go all the way to the length instead of sqrt(n) | |
| #to include all prime factors | |
| if result[i] == 0: #If this value has not been marked yet, continue | |
| for j in range(2 * i, len(result), i): | |
| result[j] += 1 #Add all the prime factors | |
| return result | |
| #We will obtain a list where array[x] represents the number of prime factors of x, | |
| #if array[x] = 0 then x is a prime |
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(): | |
| primes = sorted(list(set(list_primes(10000)) - set((list_primes(1000))))) | |
| supercandidates = [] | |
| while len(primes) != 0: | |
| curr = primes.pop() | |
| candidates = [curr] | |
| for y in primes: | |
| if sorted(str(curr)) == sorted(str(y)): | |
| candidates.append(y) |
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(): | |
| x = 100 | |
| while True: | |
| count = 1 | |
| for i in range(2, 7): | |
| if sorted(str(x)) != sorted(str(i*x)): | |
| break | |
| count += 1 | |
| if count == 6: | |
| return x |