Skip to content

Instantly share code, notes, and snippets.

from itertools import combinations, product
LOW = 1
HIGH = 40
REFERENCE_WEIGHT_COUNT = 4
def has_solution(object_weight, reference_weights):
"""returns True if there is a way to use the reference weights to correctly identify the object weight"""
guess_range = [LOW, HIGH] # >= low, <= high
# we take reference weight and a sign (+/-): + means on the right side of the scale, - means on the left
package org.maltparser.core.config;
import java.io.File;
import java.net.MalformedURLException;
import java.net.URL;
import org.maltparser.core.exception.MaltChainedException;
import org.maltparser.core.flow.FlowChartInstance;
import org.maltparser.core.flow.item.ChartItem;
import org.maltparser.core.flow.spec.ChartItemSpecification;
@erikfrey
erikfrey / merge_ldb.cpp
Created September 3, 2012 17:17
merge leveldbs
/*
* given a list of input leveldb's, merge them into a single output leveldb
*
*/
#include <iostream>
#include <algorithm>
#include <boost/program_options.hpp>
#include <boost/cstdint.hpp>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <boost/array.hpp>
#include <boost/bind.hpp>
#include <boost/asio.hpp>
namespace posix = boost::asio::posix;
class echo_client
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <boost/array.hpp>
#include <boost/bind.hpp>
#include <boost/asio.hpp>
namespace posix = boost::asio::posix;
class posix_chat_client
erik@roastbeef:~/proj$ time node child.js < bigfile > derp
real 0m6.176s
user 0m4.176s
sys 0m1.916s
erik@roastbeef:~/proj$ time cat bigfile | node child.js | cat > derp
real 0m1.504s
user 0m0.560s
sys 0m0.892s
@erikfrey
erikfrey / gist:1164496
Created August 23, 2011 06:41
node readline
erik@roastbeef:~/proj$ cat child2.js
var readline = require('readline'),
rl = readline.createInterface(process.stdin, process.stdout);
rl.on('line', function(line) {
console.log(line);
});
erik@roastbeef:~/proj$ time node child2.js < bigfile > derp
@erikfrey
erikfrey / gist:1164469
Created August 23, 2011 06:18
python, c++, node on stdio
erik@roastbeef:~/proj$ cat child.py
import sys
line = sys.stdin.readline()
while line:
line = sys.stdin.readline()
erik@roastbeef:~/proj$ time python child.py < bigfile > derp
real 0m0.073s
user 0m0.056s
>>> not None
True
>>> True is not None
True
>>> not not None
False
>>> False is not not None
File "<stdin>", line 1
False is not not None
^
>>> not None
True
>>> True is not None
True
>>> not not None
False
>>> False is not not None
File "<stdin>", line 1
True is not not None
^