Skip to content

Instantly share code, notes, and snippets.

<!--
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:
@mpenkov
mpenkov / traversal.cpp
Last active December 11, 2015 03:09
Coding Interview Practice: Tree Traversals
#include <map>
#include <set>
#include <algorithm>
#include <iostream>
using namespace std;
//
// Lessons learned:
//
@mpenkov
mpenkov / trie.py
Last active December 11, 2015 22:49
Coding Interview Practice: Tries
import sys
#
# Lessons learned:
#
# - must override object class to get __sizeof__ to work
#
class TrieNode(object):
def __init__(self, leaf):
@mpenkov
mpenkov / clobber.html
Last active December 12, 2015 05:19
Character encoding
<!--
vim: shiftwidth=2
-->
<html>
<head><title>Clobber</title></head>
<body>
<form>
<textarea id="textArea" readonly="true" rows="10" cols="70"></textarea><br/>
<input id="inputText" type="text" text="Enter some text here" size="50" value="Enter some Unicode here...">
<input id="checkbox" type="checkbox">clobber the submitted text</input>
@mpenkov
mpenkov / hanoi.html
Last active December 12, 2015 06:28
Coding Interview Practice: Stacks
<!--
vim: shiftwidth=2
-->
<html>
<head>
<title>Tower of Hanoi</title>
</head>
<body>
<script src="hanoi.js"></script>
Number of disks: