Skip to content

Instantly share code, notes, and snippets.

View jokeofweek's full-sized avatar

Dominic Charley-Roy jokeofweek

View GitHub Profile
@jokeofweek
jokeofweek / gist:10595214
Last active August 29, 2015 13:59
COMP 424 Review Questions

Search

  1. a. b.

  2. No. Suppose k = 1, then in this case it would take B as the only successor and force BC as the path to the goal even though AC is better.

Constraint Satisfaction

Games

@jokeofweek
jokeofweek / comp302review.sml
Last active December 16, 2015 15:19
comp320 review questions
(* q1: *)
fun insert (v, []) = [v]
| insert (v, (h::t)) =
if (v < h) then v::(h::t)
else h::(insert (v,t));
(* q2: *)
local
fun helper [] acc = acc
| helper (h::t) acc = helper t (insert (h, acc))
@jokeofweek
jokeofweek / jsonapi.go
Created March 22, 2013 02:27
This set of functions allows interacting with the HostIP JSON API from Go.
package main
import (
"encoding/json"
"fmt"
"io/ioutil"
"net/http"
)
// This is our type which matches the JSON object.
@jokeofweek
jokeofweek / test251A2.sh
Last active December 12, 2015 04:08
Automated tester for COMP 251 A2.
for i in {1..100}
do
vars=`expr $RANDOM % 20`
vars=`expr $vars + 2`
tests=`expr $RANDOM % $vars`
tests=`expr $tests + $RANDOM % $vars`
tests=`expr $tests + $RANDOM % $vars`
tests=`expr $tests + $RANDOM % $vars`
tests=`expr $tests + $RANDOM % $vars`
tests=`expr $tests + $RANDOM % $vars`
for (String word : list) {
if (!otherTrie.matchPrefix(trie.getPrefix(word)))
System.out.println("matchPrefix Error for word " + word + " ");
List<String> otherTrieResult = otherTrie.findCompletions(word);
List<String> trieResult = trie.getAllPrefixMatches(word);
if (!(otherTrieResult.containsAll(trieResult) && trieResult
.containsAll(otherTrieResult))) {
throw new RuntimeException("autocomplete " + word + " ");
}
}
@jokeofweek
jokeofweek / UnitTester.java
Created October 10, 2012 16:55
Assignment 2 Unit Tester
package a2posted;
import java.util.HashMap;
public class UnitTester {
public static void main(String... args) {
HashMap<String, Boolean> testCases = new HashMap<String, Boolean>();
testCases.put("foo=23", true);
testCases.put("foo= 23", false);
@jokeofweek
jokeofweek / REPL.php
Created October 18, 2011 18:48
A Simple PHP REPL
<?php
class REPL {
private $stream;
public function __construct($streamPath = 'php://stdin'){
$this->stream = fopen($streamPath, 'r');
}
public function begin(){