Skip to content

Commit

Permalink
Merge branch 'master' of https://github.com/wrq/pyjunk
Browse files Browse the repository at this point in the history
  • Loading branch information
wrq authored Apr 11, 2022
2 parents aa24f70 + 22e6624 commit 60f7206
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 0 deletions.
15 changes: 15 additions & 0 deletions junk.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import more_itertools as m

# for x in range(50):
# print(x, len(list(m.partitions(range(x)))))


def compare(start: int, offset: int, iters: int):
"a silly function for comparing growths"
a = [x for x in range(start, start+iters)]
b = [x for x in range(start+offset, start+offset+iters)]
print(f"start: {start} offset: {offset} iters: {iters}")
print(f"a: {sum(a)}")
print(f"b: {sum(b)}")

compare(1, 100, 1000000000)
12 changes: 12 additions & 0 deletions powercard.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import more_itertools


def understanding_partition_size():
for x in range(1, 30):
deck = list(range(x))
print(x, 2**x, len(list(more_itertools.partitions(deck))))


# it is clear to see that partitions(n) grows with the power of 2.
# so, the number of partitions of a 52 card deck is 2 ** 51: 2251799813685248
# 2,251,799,813,685,248

0 comments on commit 60f7206

Please sign in to comment.