Skip to content

Instantly share code, notes, and snippets.

@taylorleese
taylorleese / firstlast.py
Created January 20, 2011 04:32
Facebook Hacker Cup Online Round 1a - First or Last
import sys
from fractions import Fraction
# Facebook Hacker Cup Online Round 1a - First or Last
# http://www.facebook.com/hackercup/problems.php?round=144428782277390
def main():
with open(sys.argv[1]) as fp:
input = fp.read().split()
@taylorleese
taylorleese / dance.py
Created January 16, 2011 07:00
Facebook Hacker Cup Online Round 1a - After the Dance Battle
import sys
# Facebook Hacker Cup Online Round 1a - After the Dance Battle
# http://www.facebook.com/hackercup/problems.php?round=144428782277390
def dijkstra(graph, start, end):
dist = {}
previous = {}
for v in graph.keys():
@taylorleese
taylorleese / student.py
Created January 12, 2011 17:43
Facebook Hacker Cup Qualification Round - Studious Student
import sys
# Facebook Hacker Cup Qualification Round - Studious Student
# http://www.facebook.com/hackercup/problems.php?round=4
def lex_compare(x, y):
if x.startswith(y) and x != y:
return lex_compare(x[len(y):], y)
if y.startswith(x) and y != x:
@taylorleese
taylorleese / Scala - Fibonacci
Created October 5, 2010 21:19
Scala - Fibonacci
def fib(n: Int): Long = n match {
case _ if n <= 1 => n
case _ => fib(n-1) + fib(n-2)
}
@taylorleese
taylorleese / WPF - Bindable PasswordBox
Created July 8, 2010 17:23
WPF - Bindable PasswordBox
using System.Windows;
using System.Windows.Controls;
namespace CustomControl
{
public class BindablePasswordBox : Decorator
{
/// <summary>
/// The password dependency property.
/// </summary>