This file contains hidden or 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
(global-font-lock-mode 1) | |
(column-number-mode 1) | |
(show-paren-mode 1) | |
(setq-default fill-column 79) | |
(setq default-tab-width 2) | |
(setq js-indent-level 2) | |
(setq-default indent-tabs-mode nil) |
This file contains hidden or 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 python3 | |
import itertools | |
# The input to the algorithm. | |
N = 11 | |
def build_tree(n): | |
# This should be `limit = O(log n)`... | |
limit = (n // 2) + 1 |
This file contains hidden or 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
#!/bin/env python2 | |
from flask import Flask | |
from flask import json | |
from mimerender import FlaskMimeRender | |
app = Flask(__name__) | |
app.debug = True | |
app.testing = True | |
mimerender = FlaskMimeRender() |
This file contains hidden or 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 numpy as np | |
def GEPP(A, b, doPricing = True): | |
''' | |
Gaussian elimination with partial pivoting. | |
input: A is an n x n numpy matrix | |
b is an n x 1 numpy array | |
output: x is the solution of Ax=b | |
with the entries permuted in |
This file contains hidden or 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
# -*- coding: utf-8 -*- | |
""" | |
************************************** | |
Minimum Vertex and Edge Dominating Set | |
************************************** | |
A dominating set for a graph G = (V, E) is a subset D of V such that every | |
vertex not in D is joined to at least one member of D by some edge. The |
This file contains hidden or 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
from itertools import islice | |
from itertools import tee | |
def tails(iterable): | |
iterator = iter(iterable) | |
while True: | |
tail, iterator = tee(iterator) | |
yield tail | |
# Try to pop the next element of the iterable. If there are no |
This file contains hidden or 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
from threesum import three_sums | |
def test_three_sums(): | |
integers = [2, 4, 8, 10, -7, -10, -25] | |
expected = [(-10, 2, 8)] | |
actual = list(three_sums(integers)) | |
assert [sorted(t) for t in three_sums(integers)] == [[-10, 2, 8]] |
This file contains hidden or 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
# light.py - decides whether a Cayley table represents an associative operation | |
# | |
# Copyright 2015 Jeffrey Finkelstein. | |
# | |
# This file is part of Light. | |
# | |
# Light is free software: you can redistribute it and/or modify it under the | |
# terms of the GNU General Public License as published by the Free Software | |
# Foundation, either version 3 of the License, or (at your option) any later | |
# version. |
This file contains hidden or 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
def estimate_mean(sample, values, weights=None): | |
"""Estimates the average value of a set of elements based on the given | |
sample. | |
Parameters | |
---------- | |
sample : iterable | |
Iterable of objects. | |
values : function |
OlderNewer