Last active
April 26, 2017 06:47
-
-
Save vicalloy/7225cf8749e427882e0e70138353739a to your computer and use it in GitHub Desktop.
money
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
import random | |
def get_pkg(total_money, pkg_count): | |
pkg = random.randint(1, int(total_money * 2 / pkg_count)) | |
if (total_money - pkg) < (pkg_count - 1): | |
return get_pkg(total_money, pkg_count) | |
return pkg | |
total_money = 10000 | |
pkgs = [] | |
for i in range(30): | |
pkg = get_pkg(total_money, 30 - i) | |
if i == 29: | |
pkg = total_money | |
total_money -= pkg | |
pkgs.append(pkg) | |
pkgs = ["%s" % e for e in pkgs] | |
print(",".join(pkgs)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment