Skip to content

Instantly share code, notes, and snippets.

@fsiler
Created October 17, 2013 00:34
Show Gist options
  • Save fsiler/7017400 to your computer and use it in GitHub Desktop.
Save fsiler/7017400 to your computer and use it in GitHub Desktop.
#!/usr/bin/env python
from __future__ import division, generators, nested_scopes, print_function, with_statement
import os, readline, rlcompleter, atexit
readline.parse_and_bind("tab: complete")
readline.set_history_length(10000)
histfile = os.path.expanduser("~/.python/history")
try:
readline.read_history_file(histfile)
except IOError:
pass
def binomial(n,k):
"""return binominal coefficients for (n,k)"""
return int(reduce(lambda a,b: a*(n-b)/(b+1),xrange(k),1))
atexit.register(readline.write_history_file, histfile)
del histfile, os
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment