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 string, random | |
CHARS = string.uppercase + ' ' | |
PROGENY = 100 | |
RATE = 0.05 | |
TARGET = 'METHINKS IT IS LIKE A WEASEL' | |
genotype = lambda s : [random.choice(s) for x in xrange(len(TARGET))] | |
phenotype = '' |
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 string, random, time | |
CHARS = string.uppercase + ' ' | |
TEST = True | |
class Biosphere(object): | |
'''Attempts to find `target` by producing generations of random strings that | |
mutate by `rate` percent. Generational population is determined by | |
`progeny`. | |
''' |
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 Converter(object): | |
'''Converts a string to Brainfuck.''' | |
def __init__(self, string): | |
self.output = self._parse(string) | |
def _parse(self, string): | |
'''Takes a string, redefines it as a list containing its ASCII values, | |
rounds the values down, creates loop cells using those values, minus | |
the first decimal, i.e. 72 becomes 70 and then 7, this is because the |
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 random, time, string | |
CHARS = '-+<>[].' | |
SEED_RANGE = 350 | |
GAUSS_RANGE = 15 | |
TIMEOUT = 0.0009 | |
class Biosphere(object): | |
'''Attempts to find `target` by producing generations of random strings that | |
mutate by `self.rate` percent. Generational population is determined by |
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
# foo = shift('string',3) | |
# shift(foo, -3) | |
shift = lambda s,i=3 : ''.join(map(lambda c : chr(c + i), map(ord, s))) |
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
# big.txt here --> http://norvig.com/big.txt | |
from random import randrange, choice | |
MIN = 3 | |
MAX = 2 | |
class MarkovChain(object): | |
'''Provides the necessary functions to generate a Markov chain. | |
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
add = lambda x, y : add((x & y) << 1, x ^ y) if x != 0 else y; add(13,29) | |
def add_again(x, y): | |
if x == 0: | |
return y | |
else: | |
return add_again((x & y) << 1, x ^ y) |
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 RingBuffer(object): | |
'''This data structure provides a circular "ring" queue, limited by | |
n-number of positions as `length`. Once the ring is full, i.e. the length | |
is exceed, the head of the queue is deleted. In this way we acheive a | |
first in, first out circular buffer.''' | |
def __init__(self, length): | |
self.queue = [] | |
self.keys = [] | |
self.length = length |
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
# radioreddit stuff | |
@bot.command | |
def status(stream): | |
streams = [ | |
'rock', | |
'electronic', | |
'hiphop', | |
'random', | |
'talk', |
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
#include <stdlib.h> | |
#include <stdio.h> | |
#include <string.h> | |
#include <time.h> | |
char* ALPHABET = "ABCDEFGHIJKLMNOPQRSTUVWXYZ "; | |
char* TARGET = "ME THINKS IT IS LIKE A WEASEL"; | |
float RATE = 0.05; | |
int GENERATIONS = 250; | |
int ALPHABET_LEN = 27; |