Created
May 28, 2020 07:45
-
-
Save lyshie/d23e570254ec319b574c03158175e9fb to your computer and use it in GitHub Desktop.
Distribute
This file contains hidden or 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
#!/usr/bin/env python3 | |
def partition(num, group): | |
parts = dict() | |
m = int(num / group) | |
r = num - m * group | |
parts = [m + 1] * (r) + [m] * (group - r) | |
return parts | |
for num in range(1, 30, 1): | |
group = int((num - 1) / 10) + 1 | |
parts = partition(num, group) | |
print("%3d %3d %s" % (num, group, parts)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment