Skip to content

Instantly share code, notes, and snippets.

@fletom
Last active October 6, 2015 02:58
Show Gist options
  • Save fletom/2924758 to your computer and use it in GitHub Desktop.
Save fletom/2924758 to your computer and use it in GitHub Desktop.
A concise generator of the rows of Pascal's triangle
def pascals_triangle():
row = [1]
while True:
yield row
row = map(sum, zip([0] + row, row + [0]))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment