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 | |
# The Fibonacii matrix | |
M = np.array([[0, 1], [1, 1]], dtype=np.float32) | |
# Compute the eigendecomposition of the matrix | |
w, v = np.linalg.eig(M) | |
inv_v = np.linalg.inv(v) | |
base_case = np.array([0, 1]).T # base case as a column vector |
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 search(s, list): | |
mid = len(list) // 2 | |
while mid >= 0 and list[mid] == None: | |
mid -= 1 | |
if mid == -1: | |
raise Exception('No such element') | |
if s == list[i]: | |
return i | |
elif s < list[i]: | |
return search(s, list[:i]) |
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
template <typename T> | |
class Node | |
{ | |
public: | |
Node(T data); | |
// mutators | |
void add_edge(const Node<T>* node); | |
// accessors |
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
# reachability.py | |
# Wesley Wu, Lab 1 | |
# Bohyun Kim, Lab 1 | |
# We certify that we worked cooperatively on this programming | |
# assignment, according to the rules for pair programming | |
import prompt | |
def read_graph(filename): | |
adict = {} | |
file = open(filename) |
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 | |
def isPrime(n): | |
for i in range(2, math.sqrt(n)): | |
if n % i == 0: | |
return False | |
return True |
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 prompt | |
import predicate | |
import random | |
DartThrown = prompt.for_int('Enter number of darts to throw', is_legal= predicate.is_positive) | |
count = 0 | |
for i in range(DartThrown): | |
#print('Dart Thrown') | |
x = random.uniform(-1, 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
echo 'Initializing crawler.' | |
crawler | |
while [ 1 ]; do | |
echo 'Boo. Crawler crashed. Restarting' | |
crawler | |
sleep 1 | |
done |
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
# author -- Gio Borje | |
import random | |
class GeneticProcessor(object): | |
def __init__(self, population_size, fitness_fn): | |
self.population_size = population_size | |
self.fitness_fn = fitness_fn | |
def next_gen(self, population): |
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
int sum = 1; | |
for (int i = 0; i < 100; i++) | |
sum = sum + 1 | |
return sum // returns 101 |
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
#ifndef EVENT_H | |
#define EVENT_H | |
#include "DiscreteClock.h" | |
#include "SimulationState.h" | |
#include <functional> | |
class EventHandler; |
NewerOlder