k4st
|
codepad
|
|
k4st
|
Saved pastes by k4st:
def LCS(a, b):
# table, a down the vertical, b on the horizontal
table = [["" for _ in range(len(b) + 1)] for __ in range(len(a) + 1)]
|
view (23 lines, 6 lines of output) |
import math
print "F", math.floor(3.0 / 2.0) == math.ceil(3.0 / 2.0)
print "I", math.floor(3 / 2) == math.ceil(3 / 2)
print "Fmod", math.fmod(3.0, 2.0) == 0
|
view (6 lines, 4 lines of output) |
def back_substitution(M, X, n):
"""Compute MR = X for some n*n upper-triangular matrix M and
some n*m matrix X."""
|
view (59 lines, 1 line of output) |
dyn129-100-198-166:FLTL petergoodman$ ./bin/grail --tool=cfg-parse ./test/commandtalk.cfg
reading...
computing null set...
parsing...
looking at token 'xray'...
|
view (181 lines) |
<?php
/**
* Make an object that isn't an array into an array containing that object, or
* return the element if it is an array.
|
view (49 lines) |
# (c) 2009 Peter Goodman, all rights reserved
# Solutions for UWO CS3346a Assignment 1 Question 4
LEFT, RIGHT = 0, 1
INITIAL_STATE, GOAL_STATE = (3, 3, 0, 0, LEFT), (0, 0, 3, 3, RIGHT)
|
view (226 lines, 1453 lines of output) |
LEFT, RIGHT = 0, 1
def states():
"""Generate all possible states for the missionaries and cannibals
|
view (110 lines, 66 lines of output) |
<?php
/**
* An iterator that acts as a window to its inner-iterator. It does this by
* providing deque-like functionality (allowing shifting off the front and
|
view (150 lines) |
<?php
$arr = array(
'a', 'b', 'c', 'c', 'd','e', 'e',
'e', 'e', 'e', 'f', 'e', 'f', 'e',
|
view (19 lines) |
<?php
/**
* CodeIgniter library to interface with the Akismet API.
* @author Peter Goodman
|
view (109 lines) |
<?php
// yikes!
!defined('WP_MAIN_DIR') &&
define('WP_MAIN_DIR', dirname(dirname(dirname(dirname(__FILE__)))));
|
view (101 lines) |
<?php
require_once dirname(__FILE__). '/__include__.php';
require_once dirname(__FILE__). '/linear-state-machine.php';
|
view (108 lines) |
<?php
if(!function_exists('array_copy')) {
/**
* Make a deep copy of an array of a tuple
|
view (171 lines) |
<?php
error_reporting(E_ALL | E_STRICT);
!defined("APPPATH") && define("APPPATH", dirname(__FILE__));
|
view (272 lines) |
def matrix_chain_product(*S):
"""Given a sequence, S, of matrices, calculate the minimum number of scalar
operations needed to multiply all of them together."""
|
view (61 lines, 8 lines of output) |
def edit_distance(A, B):
"""Calculate the edit distance (levenshtein) between strings A and B.
Also, generate the longest common subsequence from the resulting matrix
after edit distance has been calculated."""
|
view (58 lines, 13 lines of output) |
def morris_pratt(P, T):
"""Search for a pattern, P, in some text, T, using the Morris-Pratt
algorithm."""
|
view (95 lines, 5 lines of output) |
def quick_sort_inplace(L):
"""Perform an in-place quicksort of the list L."""
# used for finding random numbers
|
view (69 lines, 3 lines of output) |
def merge_sort(A):
"""Merge sort a list using the divide-and-conquer method."""
# we will need these two functions to divide a list
|
view (56 lines, 15 lines of output) |
def radix_sort(A, highest=None):
"""Stable sort an array A of positive integers in logarithmic time by sorting
the numbers one digit at a time, starting with the most significant
digit. The sorting by digits is done using a simplified bucket sort."""
|
view (78 lines, 2 lines of output) |
def longest_common_subsequence(A, B):
"""Determine how long the longest common subsequence of A and B are, then
reconstruct it."""
|
view (49 lines, 2 lines of output) |
def boyer_moore(P, T):
"""Search for P in T using the Boyer Moore algorithm assuming a ascii
character set."""
|
view (67 lines, 1 line of output) |