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
# Euler project problem 17 | |
words = ['', 'one', 'two', 'three', 'four','five', 'six', 'seven', 'eight', 'nine', 'ten', 'eleven', 'twelve', 'thirteen', 'fourteen', 'fifteen', 'sixteen', 'seventeen', 'eighteen', 'nineteen', 'twenty', 'thirty', 'forty', 'fifty', 'sixty', 'seventy', 'eighty', 'ninety'] | |
debug = 0 | |
def build_word(n): | |
# --debug |
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
"Calculates the binary huffman code for the given characters and their frequencies." | |
from copy import copy | |
freqs = {'a': 20, 'b': 10, 'c': 12, 'd': 5, 'e': 15, 'z': 65 } | |
class Node: | |
def __init__(self, ch='', freq=-1, code=None): |
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
elements = ['FINDING_ID', 'FINDING_STATUS', 'FINDING_DETAILS', 'SCRIPT_RESULTS', 'TOOL', 'TOOL_VERSION', 'AUTHENTICATED_FINDING', 'GD_VUL_NAME', 'GD_SEVERITY'] | |
def process_finding(finding): | |
global elements | |
d = {} | |
for element in elements: | |
result = finding.getElementsByTagName(element) | |
# Element dne |
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
""" | |
Generate graph of prerequisites. | |
http://www.csupomona.edu/~cs/student/undergrad.shtml | |
""" | |
import urllib | |
import re | |
data = urllib.urlopen('http://www.csupomona.edu/~cs/student/undergrad.shtml').read() |
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
digraph classes { | |
cs490; | |
cs299; | |
cs130; | |
cs375; | |
cs241 -> cs311; | |
cs264 -> cs408; | |
cs311 -> cs408; | |
cs400; |
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 re | |
import os | |
import glob | |
fnames = glob.glob('*.flac') | |
# encode files | |
for f in fnames: |
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
// copy constructor | |
Matrix::Matrix(const Matrix &rhs) | |
{ | |
if (this != &rhs) { | |
// newly created object | |
this->a = NULL; | |
// copy rhs to this | |
*this = rhs; |
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
# Euler 184 | |
import math | |
class Point: | |
def __init__(self, x, y): | |
self.x = x | |
self.y = 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
import math | |
radius = 105 | |
width = (radius * 2) - 1 | |
points = [] | |
for x in xrange(-radius, radius+1): | |
for y in xrange(-radius, radius+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 sys | |
import math | |
if len(sys.argv) > 1: | |
radius = int(sys.argv[1]) | |
else: | |
radius = 5 |
OlderNewer