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
expect = (a,b) -> | |
[a,b] = [a.join(), b.join()] | |
if a != b | |
console.log """ | |
Expect failed! | |
[#{a}] != [#{b}] """ | |
else console.log "PASS! [#{a}]" | |
# Preprocesses P to generate list of occurances of suffixs within | |
# the pattern. |
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
PASSED = 0 | |
check_sorted = (was, now) -> | |
if !now.reduce ((a,c,i) -> a && (!now[i+1]? || now[i] < now[i+1])), true | |
throw new Error """\n | |
Was: [#{was}] | |
Now: [#{now}]\n""" | |
else | |
++PASSED |
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 time interval between start and end, formatted as | |
# 17928 -> 17s 928ms | |
timeElapsed = (start, end) -> | |
diff = end - start | |
"#{Math.floor(diff/1000)}s #{Math.floor(diff%1000)}m" | |
# Helpers for the permute function | |
arrayExcept = (A, idx) -> | |
(A = A[0..]).splice idx, 1; A |
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
# Simply rounds to four digits | |
dp = (num) -> | |
Math.round(10000*num)/10000 | |
# Calculates empirical probability of | |
lazyCheck = (P, k) -> | |
RUNS = 500000 | |
avg = 0 | |
for i in [1..RUNS] | |
heads = P.reduce(((a,c) -> |
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
# Making comparisons between two DNA sequences can become a hard computational | |
# problem, due to the inexact definition of organic similarity. | |
# | |
# When making comparisons between two sequences, a useful definition of | |
# similarity is the largest subsequence present within both sequences, where a | |
# subsequence is defined as such... | |
# | |
# Given X = { X1, X2, ..., Xm } | |
# and Z = { Z1, Z2, ..., Xk }... | |
# |
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
var Track = (function() { | |
function Track(title, artist) { | |
this.title = title || 'Untitled'; | |
this.artist = artist || 'Unknown'; | |
} | |
Track.prototype.toString = function() { | |
return this.title + ',\t\t' + this.artist; | |
}; |
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
# Given a list V of item values, and W of item weights, where item i | |
# has value V[i] and weight W[i], find the optimal selection of i to | |
# sure fill the knapsack of capcity k with fractions of items. | |
# | |
# The values are required to be sorted by descending order of value | |
# per pound, in order to enable a greedy choice. | |
# | |
# The sort incurs a cost of O(n log(n)), assuming efficient merge | |
# sort. | |
# |
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
> module Ex3FunctionsCodeGenerator where | |
> import Ex3FunctionsTypes | |
> import Data.List | |
----------------------------------------------------------- | |
Solution for Compilers exercise 3 | |
Paul Kelly Imperial College London 2009 | |
----------------------------------------------------------- | |
Fill in the gaps... |
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
Anonymous UUID: 9DA07A69-940A-DF72-455D-54DAD821BB68 | |
Wed May 21 22:44:27 2014 | |
panic(cpu 0 caller 0xffffff7fa336bfb0): "GPU Panic: [<None>] 3 0 a0 d9 9 8 0 3 : NVRM[0/1:0:0]: Read Error 0x00000144: CFG 0xffffffff 0xffffffff 0xffffffff, BAR0 0x102c00000 0xffffff81f8d94000 0x0e7150a2, D0, P2/4\n"@/SourceCache/AppleGraphicsControl/AppleGraphicsControl-3.4.35/src/AppleMuxControl/kext/GPUPanic.cpp:127 | |
Backtrace (CPU 0), Frame : Return Address | |
0xffffff81e307cbe0 : 0xffffff8020e22fa9 | |
0xffffff81e307cc60 : 0xffffff7fa336bfb0 | |
0xffffff81e307cd30 : 0xffffff7fa185a22c | |
0xffffff81e307cdf0 : 0xffffff7fa1924106 | |
0xffffff81e307ce30 : 0xffffff7fa1b47e54 |
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
#!/usr/bin/env coffee | |
# vi: set foldmethod=marker | |
fs = require 'fs' | |
path = require 'path' | |
sSplitter = require 'stream-splitter' | |
$q = require 'q' | |
coffee = require 'coffee-script' | |
spawn = (require 'child_process').spawn | |
exec = (require 'child_process').exec |