Skip to content

Instantly share code, notes, and snippets.

Keybase proof

I hereby claim:

  • I am skovorodkin on github.
  • I am skovorodkin (https://keybase.io/skovorodkin) on keybase.
  • I have a public key ASDS0gCBgFjeLR6sekabR54T_HgG6_dNRuxFxgg4Uhl1Xwo

To claim this, I am signing this object:

@skovorodkin
skovorodkin / partitions_with_permutations.py
Last active August 25, 2017 14:20
Partitions with permutations
# https://stackoverflow.com/questions/10035752/elegant-python-code-for-integer-partitioning/44209393?#comment78597595_44209393
from itertools import chain, permutations
def partitions(n, I=1):
yield (n,)
for i in range(I, n//2 + 1):
for p in partitions(n-i, i):
yield (i,) + p