CC: Compiler construction ESOP: FASE: FoSSaCS:
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
solution time [s] memory [bytes] | |
peter.hs .163 7479296 | |
radu.hs .160 7495680 | |
duncan.hs 176.97 7467008 | |
tim.hs .160 7471104 Files out and out.ref differ | |
nicolas.lhs .460 19001344 Files out and out.ref differ | |
lennart.hs 2134.98 7467008 Files out and out.ref differ | |
This was run in /dev/shm (that is, not using the HDD) on a computer with two cores at 4788 bogomips each (Intel i3 @2.4GHz), and 4GB of RAM. |
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
cache = dict() # cache[x] is a map from weights to paths s->x | |
s = 0 # source | |
def find(t): | |
if t in cache: return cache[t] | |
if t == s: | |
return dict([(0,[s])]) | |
r = dict() | |
for (x, w) in pred(t): | |
for (ww, path) in find(x): |
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
class Benchmark { | |
public final boolean run() { | |
if (++iteration == 1) prepare(); | |
if (validateOutput) { | |
System.setOut(out); // this is where System.out is redefined | |
out.openLog(); | |
} | |
try { iterate(); } | |
finally { | |
if (validateOutput) { |
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
diff -r e5fa13aae1cc Python/bltinmodule.c | |
--- a/Python/bltinmodule.c Tue Dec 31 06:52:47 2013 -0500 | |
+++ b/Python/bltinmodule.c Wed Jan 01 15:46:01 2014 +0000 | |
@@ -1559,14 +1559,15 @@ | |
equivalent to (x**y) % z, but may be more efficient (e.g. for ints)."); | |
- | |
static PyObject * | |
builtin_print(PyObject *self, PyObject *args, PyObject *kwds) |
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
include <stdio.h> | |
int main() { | |
const int n = 200; | |
int data[n]; | |
data[0]=0; data[1]=2; | |
int i, j; | |
i = j = 0; | |
int state = 0; | |
while (j < n) { | |
printf("%d\n",data[j]); |
Questions: https://github.com/regehr/assert_quiz/blob/master/assert_quiz.md
- bad, should handle error sensibly
- bad, debug builds don't even alloc
- bad, should handle error sensibly
- ?, assert ok, but code around clearly bad: the hash_function has no idea what lenght is, and no modulo done after
- bad, should handle error sensibly
- kinda ok. You probably want a way to turn off expensive assertions, though. This way you can run prog with all asserts on small tests, and with cheap asserts on big tests (an with no asserts in release -- if you so fancy).
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 Data.Array.IArray (Array, array, (!), elems) | |
imap :: (Int -> a -> b) -> [a] -> [b] | |
imap = m 1 | |
where | |
m _ _ [] = [] | |
m i f (x : xs) = (f i x) : m (i + 1) f xs | |
solve :: [Int] -> Int | |
solve xs = n - cyclesCount |
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 | |
M = 10 | |
cache = [[None for k in range(2**b+1)] for b in range(M)] | |
def maxo(a, b): | |
if b is None: | |
return a | |
if a is None: | |
return b |
OlderNewer