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
| import networkx as nx | |
| import matplotlib.pyplot as plt | |
| from sympy import factorint | |
| def f(n): | |
| result = factorint(n) | |
| result = result.items() | |
| result = [n*e//p for p, e in result] | |
| result = sum(result) |
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
| import numpy as np | |
| from scipy.spatial.distance import pdist, squareform | |
| from itertools import combinations | |
| sph = 2000 | |
| def monte_plot(sph): | |
| X = 100 * np.random.random(sph * 2).reshape(sph, 2) | |
| radial_dists = np.sqrt(np.sum((X - np.array([50,50]))**2, axis=1)) | |
| plot_X = X[radial_dists <= 3.999] |
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
| import numpy as np | |
| def multiminor(arr, I): | |
| modes = len(arr.shape) | |
| assert modes == len(I) | |
| result = arr.copy() | |
| for mode in range(modes): | |
| result = np.delete(result, I[mode], axis=mode) |
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
| from math import factorial | |
| import time | |
| n = 241779 | |
| prod_n = factorial(n) | |
| while 1: | |
| prod_n = prod_n * (n + 1) | |
| str_n = str(prod_n) | |
| n += 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 exp_seq(iterable): | |
| '''Calculates the exponent tower of a sequence of numbers.''' | |
| a = iterable[0] | |
| for i in iterable[1:]: | |
| a = a**i | |
| return a |
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 prime_factors(n): | |
| '''Brute-force method of searching for primes.''' | |
| i = 2 | |
| factors = [] | |
| while i * i <= n: | |
| if n % i: | |
| i += 1 | |
| else: | |
| n //= i | |
| factors.append(i) |
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
| import numpy as np | |
| def mult_pers(n): | |
| if len(str(n)) == 1: | |
| return n | |
| else: | |
| prod = np.prod([int(i) for i in str(n)]) | |
| return mult_pers(prod) |
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
| import collections | |
| def prime_factors(n): | |
| '''Brute-force method of searching for primes.''' | |
| i = 2 | |
| factors = [] | |
| while i * i <= n: | |
| if n % i: | |
| i += 1 | |
| else: |
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
| from itertools import chain, combinations | |
| from random import sample | |
| import matplotlib.pyplot as plt | |
| def powerset(iterable): | |
| s = list(iterable) | |
| return chain.from_iterable(combinations(s, r) for r in range(len(s)+1)) | |
| pX = [set(i) for i in powerset(list(range(10)))] |
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
| import matplotlib.pyplot as plt | |
| import numpy as np | |
| import pandas as pd | |
| import seaborn as sns | |
| x = np.random.normal(size=1000) | |
| y1 = np.cos(x) | |
| y2 = np.sin(x) |