Skip to content

Instantly share code, notes, and snippets.

# 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):
echo 'Initializing crawler.'
crawler
while [ 1 ]; do
echo 'Boo. Crawler crashed. Restarting'
crawler
sleep 1
done
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)
import math
def isPrime(n):
for i in range(2, math.sqrt(n)):
if n % i == 0:
return False
return True
# 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)
template <typename T>
class Node
{
public:
Node(T data);
// mutators
void add_edge(const Node<T>* node);
// accessors
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])
<michaelrose> phogg, it still ought to be illegal to restrict computers(aka phones) in ways that subvert the OWNERS right to use their own device please note that even a subsidized phone is SOLD to the new OWNER
<phogg> michaelrose: if you want to buy a restricted device that is clearly labeled as such I see no reason that it should be illegal just to save you from yourself
<michaelrose> doubly so when the device is made possible by free software, taking the communities work to be used in a device that is locked thusly is as good as stealing from the entire foss community
<phogg> michaelrose: now, failing to *offer* any unrestricted devices perhaps should be illegal and *misleading the customer* about whether it's restricted should be illegal.
<bls> stealing from the OSS community? what a load of crap
<reisio> michaelrose: well, it probably already _is_ illegal, at least in the USA
<phogg> michaelrose: it is not theft to comply with the licenses under which the software was released, even if you find the use
// linked_list.rs:11:25: 11:26 error: expected one of `;`, `}` but found `:`
// linked_list.rs:11 ListIterator<T> { data: &self }
enum List<T> {
Cons(T, ~List<T>),
Nil
}
struct ListIterator<T> { data: &List<T> }
''' take from python.org example, using hot_swapping variables method '''
def fib_hotswap(n):
a = 1
b = 1
for _ in range(1,n+1):
tmp = a + b
b = a
a = tmp
return b