Skip to content

Instantly share code, notes, and snippets.

@mpenkov
mpenkov / coins.py
Last active August 29, 2015 13:56
Coding for Interviews: Dynamic Programming
import copy
def coinChangePossibleSolutions(amount, denominations):
"""Return the total number of ways of obtaining the specified amount using an unlimited number of coins of the specified denominations."""
#
# The cache keeps a mapping of amounts to a set of arrangements of coins.
# We use set to keeps solutions unique.
# Each arrangement is represented as a tuple, since the mutable lists aren't hashable and cannot be kept in the above set.
#
cache = {}
@mpenkov
mpenkov / qunit-1.11.0.css
Last active August 29, 2015 13:57
Coding for Interviews: The Staque
/**
* QUnit v1.11.0 - A JavaScript Unit Testing Framework
*
* http://qunitjs.com
*
* Copyright 2012 jQuery Foundation and other contributors
* Released under the MIT license.
* http://jquery.org/license
*/
<style>
#chart svg {
height: 400px;
}
/* http://stackoverflow.com/questions/18530459/nvd3-js-bigger-points-in-a-line-chart */
.nvd3 .nv-groups .nv-point {
stroke-opacity: 0.2 !important;
stroke-width: 10px;
}
@mpenkov
mpenkov / keybase.md
Created February 5, 2015 06:27
keybase.md

Keybase proof

I hereby claim:

  • I am mpenkov on github.
  • I am mpenkov (https://keybase.io/mpenkov) on keybase.
  • I have a public key whose fingerprint is A022 9250 8FCD 119E C2BA 95E3 2A45 33DE C003 2C03

To claim this, I am signing this object:

<!--
vim: shiftwidth=2
-->
<html>
<head>
<title>#114: World Ladder Steps</title>
</head>
<body>
<h1>#114: World Ladder Steps</h1>
<a href="http://www.reddit.com/r/dailyprogrammer/comments/149kec/1242012_challenge_114_easy_word_ladder_steps/">Reddit Daily Programmer #114</a><br/>
@mpenkov
mpenkov / Makefile
Last active October 13, 2015 22:39
Coding Interview Practice: Hashmap
CFLAGS=-ggdb -Wall
all: hashmap.out
# $< the dependencies
# $@ the target
hashmap.out: hashmap.o
gcc -Wall -ggdb $< -o $@
clean:
@mpenkov
mpenkov / Makefile
Last active December 9, 2015 23:38
Coding Interview Practice: Binary Search Trees
CFLAGS=-ggdb -Wall
all: is_bst.out
# $< the dependencies
# $@ the target
is_bst.out: is_bst.o
g++ -Wall -ggdb $< -o $@
clean:
@mpenkov
mpenkov / merge.py
Last active December 10, 2015 03:08
Coding Interview Practice: MergeSort merge step
#
# lessons learnt:
#
# - python's list has no find() method -- the correct name is index()
# - next() is a built-in Python function -- http://stackoverflow.com/questions/1733004/python-next-function
#
def merge(arrays):
result = list()
while arrays:
heads = [a[0] for a in arrays]
@mpenkov
mpenkov / mergesort.py
Last active December 10, 2015 05:10
merge sort in Python
def mergesort(array, start, end):
if end - start < 2:
#
# Do nothing.
#
return
half = (end-start)/2
#
# Divide and conquer step.
#
@mpenkov
mpenkov / Makefile
Last active December 10, 2015 13:48
Coding Interview Practice: Linked Lists
CFLAGS=-ggdb -Wall
all: linkedlist.out
# $< the dependencies
# $@ the target
linkedlist.out: linkedlist.o
gcc -Wall -ggdb $< -o $@
clean: