This file contains 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 matplotlib import pyplot as plt | |
from matplotlib import animation | |
fig = plt.figure() | |
ax = plt.axes(xlim=(0, 1), ylim=(0, 1)) | |
line, = ax.plot([], [], lw=2) | |
def init(): | |
line.set_data([], []) |
This file contains 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 | |
# GENERAL FORMAT | |
# Here, f stands for function, a stands for the beginning of the interval, b stands for the end, and n stands for the number of subdivisions you want to do. | |
# LEFT RIEMANN PLOT | |
def plotleftriemannsum(f, a, b, n): | |
# plot the function | |
x = numpy.linspace(a, b) |
This file contains 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 count(n, j = 0): | |
if n > 1: | |
if n % 2 == 1: | |
return count(n//2, j+1) | |
else: | |
return count(n//2,j) | |
elif n == 1: | |
return j+1 | |
else: | |
return j |
This file contains 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 time | |
# GET THE DIGITS OF PI | |
def bbp(start, finish): | |
def bbp_formula(n): | |
return (4/(8*n+1)-2/(8*n+4)-1/(8*n+5)-1/(8*n+6))*(1/16)**n | |
ls = [i for i in range(start, finish+1)] | |
x= sum(list(map(lambda x: bbp_formula(x), ls))) | |
return [int(i) for i in str(x) if i.isdigit()] |
This file contains 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 smtplib | |
import random | |
from email.message import EmailMessage | |
# PRIVATE EMAIL INFO | |
# (This is your email. Note this is not secure, so don't do this on public networks.) | |
gmail_sender = 'sender@gmail.com' | |
gmail_passwd = 'password' |
This file contains 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 repeating_number(st): | |
from itertools import islice, chain | |
def breakup(lis, size): | |
return filter(None, map(lambda x: list(islice(lis, x, x+size)) if len(list(islice(lis, x, x+size))) == size else | |
None, [i for i in range(len(lis))])) | |
def count(lis): | |
return dict(filter(lambda x: x[1] != 1, map(lambda x: (tuple(x), len(list(filter(lambda x: x, | |
map(lambda y: y == x, lis))))), lis))) |
This file contains 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 urllib.request | |
from bs4 import BeautifulSoup | |
# Find out if the movies selected are on their websites. Note this is very susceptible to misspellings of the movie. | |
# Check if it's on hulu by seeing if the availabilityStarts option is on. Movies or shows that are not yet on Hulu | |
# do not have this feature. | |
#Change the movieName to be in a nicer format |
This file contains 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
class Player: | |
def __init__(self, deck): | |
self.deck = deck | |
self.battlefieldl = [] | |
def can_play(self): | |
return len(self.deck) | |
def battlefield(self, playvalue): | |
self.battlefieldl = [self.deck.pop(0) for i in range(min(playvalue, 4))] |
This file contains 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
# TODO: Read the summary of http://ieeexplore.ieee.org/document/5461802/. It talks a bit about how we can construct counterexamples from prior counterexamples. Maybe James needs to prove that all Ramsey graphs Gi exist as subgraphs of graphs G(i+1)? | |
# TODO: In the checking for all cliques, we can take a large subset instead of scanning the entire thing, narrowing down all possibilities to a smaller subset to search through. | |
# uses itertools to generate all tuples for k-clique checking | |
from itertools import combinations | |
# reduce container items | |
from functools import reduce | |
# uses random for the random graph generator | |
import random | |
# to time functions |
This file contains 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 math | |
import warnings | |
#find the mean of a list | |
def mean(list): | |
x = 0 | |
for i in list: | |
x+=i | |
return (x/len(list)) |
NewerOlder