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 warnings | |
try: | |
import euclideanalgorithm as ea | |
except: | |
warnings.warn('make sure to import the euclidean algorithm program') | |
#From Gallian | |
#Finds the size of the automorphism group of the cyclic integer group of size n | |
def find_automorphism(n): |
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
//Tic tac toe game in c++ | |
#include <iostream> | |
#include <stdlib.h> | |
#include <string> | |
using namespace std; |
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
// Blackjack | |
#include <iostream> | |
#include <cstdlib> | |
using namespace std; | |
#define RESET "\033[0m" | |
#define BLACK "\033[30m" /* Black */ |
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 urllib2 | |
import time | |
import text | |
import smtplib | |
#This is configured for gmail, specifically. | |
def sendEmail(username, password, msg, toaddrs): | |
fromaddr = username | |
server = smtplib.SMTP('smtp.gmail.com', 587) | |
server.ehlo() |
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
try: | |
import networkx as nx | |
except ImportError: | |
raise ImportError('Requires networkx') | |
def pageranker(g, damp, iterations): | |
#Does this for a set amount of iterations. | |
#In the future, may add convergence conditions. | |
#Not optimal for large graphs. Should probably store the connected_to list somewhere instead of calling it each time. | |
dict_of_ranks = {} |
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 warnings | |
def warn(m,n): | |
#If m,n are not integers, or are not less than 0, return a warning | |
if type(m) != int or type(n) != int or m < 0 or n < 0: | |
warnings.warn("Input was not a strictly positive integer") | |
def euclidean_division(m, n): | |
#The Euclidean division algorithm takes two inputs, m and n in this case, and returns two values which represent | |
#q and r such that, if m > n, m = qn + r, where 0 <= r < n. |
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 warnings | |
#this is just for notational simplicity | |
def degree(f): | |
try: | |
return len(f)-1 | |
except: | |
return 0 | |
# ----------------------------------------------------------------------------------------------------------------------- | |
#also for notational simplicity |
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
#Generates the truth table for n variables | |
def truthtable (n): | |
if n < 1: | |
return [[]] | |
subtable = truthtable(n-1) | |
return [ row + [v] for row in subtable for v in [0,1] ] | |
#Prints the first truth table in a nice manner. | |
def print_truth_table(lis, num_of_variables): | |
stri = "| " |
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 warnings | |
#----------------------------------------------------------------------------------------------------------------------- | |
#power function | |
#python has one built in but the point of this program is to do unecessary things for practice | |
def power(x, pow): | |
if type(pow) != int and pow > 0: | |
warnings.warn("pow needs to be an integer value greater than 0") | |
if pow == 0: | |
return 1 | |
for i in range(pow-1): |
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)) |
OlderNewer