no Homebrew required
$ cd /usr/local/src
$ curl -OL http://nginx.org/download/nginx-1.12.2.tar.gz
$ tar -xvzf nginx-1.12.2.tar.gz && rm nginx-1.12.2.tar.gz
class Hashmap(object): | |
""" | |
character holding hash map | |
""" | |
def __init__(self, hash_fn, length=100): | |
assert hasattr(hash_fn, '__call__'), 'You must provide a hash function' | |
self._buckets = [None] * length | |
self.hash_len = length | |
self.hash_fn = hash_fn |
#!/usr/bin/env bash | |
##################################################### | |
# This script is compatible with SOLR 5|6.x only | |
##################################################### | |
SOLR_PORT=${SOLR_PORT:-8983} | |
SOLR_VERSION=${SOLR_VERSION:-5.3.1} | |
version=$SOLR_VERSION |
class Node(object): | |
def __init__(self, val): | |
self.val = val | |
self.left = None | |
self.right = None | |
def __lt__(self, val): | |
return self.val < val | |
def __gt__(self, val): |
(defn count-change [money coins] | |
(cond | |
(= money 0) 1 | |
(or (< money 0) (empty? coins)) 0 | |
:else (+ | |
(count-change (- money (first coins)) coins) | |
(count-change money (rest coins))))) |
import heapq | |
def heappush(heap, val): | |
heapq.heappush(heap, -val) | |
def heappop(heap): | |
return -heapq.heappop(heap) | |
def heapify(arr): | |
for i in xrange(len(arr)): |
'use strict'; | |
var assert = require('assert'); | |
var log = console.log; | |
// undirected graph | |
function Graph() { | |
this.nodes = []; | |
this.edges = {}; | |
this.dists = {}; |
/** | |
* Longest interval in an array | |
* Implemented with that graph algo BFS | |
* [1, 3, 7, 4, 2, 10, 8] should ouput [1, 4] | |
**/ | |
'use strict'; | |
var log = console.log; | |
// Builds a undirected graph based on an interval value |
""" | |
Given a 2D board and a word, find if the word exists in the grid. | |
The word can be constructed from letters of sequentially adjacent cell, | |
where adjacent cells are those horizontally or vertically neighboring. | |
The same letter cell may not be used more than once. | |
input: ASADB, ABCCED | |
https://www.codeeval.com/open_challenges/65/ | |
""" |
class Node(object): | |
def __init__(self, key, parent=None): | |
self.key = key | |
self.parent = parent | |
self.left = None | |
self.right = None | |
def has_children(self): return len(self) > 0 | |
def delete(self, node): |