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 math | |
def isPrime(n): | |
for i in range(2, math.sqrt(n)): | |
if n % i == 0: | |
return False | |
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
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 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
echo 'Initializing crawler.' | |
crawler | |
while [ 1 ]; do | |
echo 'Boo. Crawler crashed. Restarting' | |
crawler | |
sleep 1 | |
done |
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
# 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 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
int sum = 1; | |
for (int i = 0; i < 100; i++) | |
sum = sum + 1 | |
return sum // returns 101 |
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
#ifndef EVENT_H | |
#define EVENT_H | |
#include "DiscreteClock.h" | |
#include "SimulationState.h" | |
#include <functional> | |
class EventHandler; |
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
#ifndef BASECLASS_H | |
#define BASECLASS_H | |
#include <string> | |
#include <iostream> | |
template <class Derived> | |
class BaseClass | |
{ | |
public: |
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 sqrt | |
def prob10(mass, height, radius, mom_of_inertia, friction_work): | |
g = 9.8 | |
# potential energy | |
mgh = mass * g * height | |
# total work after descent | |
work = mgh + friction_work | |
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
# No progress | |
def algo1(): | |
while turn != i: | |
# no-op | |
# crit section | |
turn = j | |
# remainder section | |
# No progress | |
def algo2(): |
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
#include <thread> | |
#include <mutex> | |
class semaphore { | |
public: | |
semaphore(unsigned int count) : count_(count) {} | |
void wait() { | |
std::lock_guard<std::mutex> lock(mutex_); | |
while (!count_) |