[ create a new paste ] login | about

k4st

Name: Peter Goodman
Email:
Site/Blog: http://www.petergoodman.me
Location: Toronto
Default language: Plain Text
Favorite languages: C++
About:

Saved pastes by k4st:

C, pasted on Aug 2:
1
2
3
4
#include <stdlib.h>
#include <stdio.h>

/// binary tree node type
...
view (109 lines, 32 lines of output)
Python, pasted on Nov 14:
1
2
3
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)
Python, pasted on Oct 11:
1
2
3
4
5
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)
C++, pasted on Apr 22:
1
2
3
4
5
#include <cstdio>

class Foo {
public:
Foo(void) throw() { }
...
view (23 lines, 4 lines of output)
C++, pasted on Apr 22:
1
2
3
4
5
#include <cstdio>

class Foo {
public:
Foo(void) throw() { }
...
view (23 lines, 4 lines of output)
Python, pasted on Mar 24:
1
2
3
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)
Plain Text, pasted on Mar 12:
1
2
3
4
5
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)
Python, pasted on Jan 15:
1
2
3
4
5
def ignore(obj):
    return None

def identity(obj):
    return obj
...
view (25 lines)
C++, pasted on Jan 5:
1
2
3
4
5
/*
 * main.cpp
 *
 *  Created on: Dec 8, 2010
 *      Author: Peter Goodman
...
view (146 lines)
C++, pasted on Jan 4:
1
2
3
4
5
/*
 * main.cpp
 *
 *  Created on: Dec 8, 2010
 *      Author: Peter Goodman
...
view (146 lines)
C++, pasted on Jan 3:
1
2
3
4
5
/*
 * main.cpp
 *
 *  Created on: Dec 8, 2010
 *      Author: Peter Goodman
...
view (118 lines)
Python, pasted on Nov 28:
1
2
3
4
M = { }

def term(t):
    def match(l,s,ret):
...
view (61 lines, 5 lines of output)
Python, pasted on Jun 26:
1
2
3
4
from itertools import product
from copy import deepcopy

class Contradiction(Exception):
...
view (134 lines)
PHP, pasted on Dec 7:
1
2
3
4
5
<?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)
Python, pasted on Nov 7:
1
2
3
4
5
NO_PLAYER = 0
PLAYER_1 = 1
PLAYER_2 = 2

def search(seq):
...
view (109 lines, 236 lines of output)
Python, pasted on Nov 7:
1
2
3
4
5
NO_PLAYER = 0
PLAYER_1 = 1
PLAYER_2 = 2

def search(seq):
...
view (108 lines, 228 lines of output)
Python, pasted on Oct 6:
1
2
3
4
5
# (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)
Python, pasted on Oct 3:
1
2
3
4
LEFT, RIGHT = 0, 1

def states():
    """Generate all possible states for the missionaries and cannibals 
...
view (110 lines, 66 lines of output)
C, pasted on Jun 27:
1
2
3
4
5
/*
 * regexp-parser.c
 *
 *  Created on: Jun 22, 2009
 *      Author: petergoodman
...
view (829 lines)
C, pasted on Jun 25:
1
2
3
4
5
/*
 * regexp-parser.c
 *
 *  Created on: Jun 22, 2009
 *      Author: petergoodman
...
view (487 lines)
C, pasted on Jun 25:
1
2
3
4
5
/*
 * regexp-parser.c
 *
 *  Created on: Jun 22, 2009
 *      Author: petergoodman
...
view (490 lines)
Python, pasted on Mar 31:
1
2
3
4
def sum1to(n):
    """
    choose2(int) -> int
    
...
view (27 lines, 1 line of output)
Plain Text, pasted on Feb 3:
1
2
3
4
5

Requirements
    Overview of types:
        Seller
...
view (144 lines)
PHP, pasted on Dec 10:
1
2
3
4
5
<?php

/**
 * $header
 * @copyright Copyright 2007, Peter Goodman
...
view (453 lines)
PHP, pasted on Dec 9:
1
2
3
4
5
<?php

class Query {
    public function execute() {
        
...
view (77 lines, 8 lines of output)
PHP, pasted on Nov 29:
1
2
3
4
5
<?php

/* $Id: help.php 172 2008-07-23 15:48:01Z peter.goodman $ */

/**
...
view (422 lines, 64 lines of output)
PHP, pasted on Nov 29:
1
2
3
4
5
<?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, pasted on Oct 7:
1
2
3
4
5
<?php

$arr = array(
    'a', 'b', 'c', 'c', 'd','e', 'e',
    'e', 'e', 'e', 'f', 'e', 'f', 'e',
...
view (19 lines)
PHP, pasted on Jun 17:
1
2
3
4
5
<?php

/**
 * CodeIgniter library to interface with the Akismet API.
 * @author Peter Goodman
...
view (109 lines)
PHP, pasted on Jun 8:
1
2
3
4
5
<?php

error_reporting(E_ALL | E_STRICT);

define('DIR_WORKING', dirname(__FILE__));
...
view (129 lines)
PHP, pasted on Jun 8:
1
2
3
4
5
<?php

error_reporting(E_ALL | E_STRICT);

define('DIR_WORKING', dirname(__FILE__));
...
view (97 lines)
PHP, pasted on May 29:
1
2
3
4
5
<?php

error_reporting(E_ALL | E_STRICT);

/**
...
view (491 lines)
PHP, pasted on May 29:
1
2
3
4
5
<?php

error_reporting(E_ALL | E_STRICT);

/**
...
view (52 lines, 70 lines of output)
PHP, pasted on May 27:
1
2
3
4
5
<?php

// yikes!
!defined('WP_MAIN_DIR') && 
    define('WP_MAIN_DIR', dirname(dirname(dirname(dirname(__FILE__)))));
...
view (101 lines)
PHP, pasted on May 27:
1
2
3
4
<?php

require_once dirname(__FILE__). '/__include__.php';
require_once dirname(__FILE__). '/linear-state-machine.php';
...
view (108 lines)
PHP, pasted on May 27:
1
2
3
4
5
<?php

require_once dirname(__FILE__). '/__include__.php';

/**
...
view (215 lines)
PHP, pasted on May 25:
1
2
3
4
5
<?php

if(!function_exists('array_copy')) {
    /**
     * Make a deep copy of an array of a tuple
...
view (171 lines)
PHP, pasted on May 25:
1
2
3
4
5
<?php

error_reporting(E_ALL | E_STRICT);

!defined("APPPATH") && define("APPPATH", dirname(__FILE__));
...
view (272 lines)
PHP, pasted on May 23:
1
2
3
4
5
<?php

/**
 * Exception class for the XMLDocument class.
 */
...
view (211 lines, 34 lines of output)
Plain Text, pasted on May 22:
1
2
3
4
5
Download TARs of:

php
apache httpd
newest MySQL
...
view (89 lines)
Python, pasted on Apr 15:
1
2
3
4
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)
Python, pasted on Apr 14:
1
2
3
4
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)
Python, pasted on Apr 14:
1
2
3
4
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)
Python, pasted on Apr 14:
1
2
3
4
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)
Python, pasted on Apr 13:
1
2
3
4
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)
Python, pasted on Apr 13:
1
2
3
4
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)
Python, pasted on Apr 13:
1
2
3
4
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)
Python, pasted on Apr 13:
1
2
3
4
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)
Python, pasted on Apr 13:
1
2
3
def quick_sort(A, compare=None):
    """Perform a quicksort on a list of items, A, by recursively dividing 
       and conquering through partitioning."""
...
view (52 lines, 2 lines of output)