-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'master' of https://github.com/wrq/pyjunk
- Loading branch information
Showing
2 changed files
with
27 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |