Skip to content

Instantly share code, notes, and snippets.

@vicalloy
Last active April 26, 2017 06:47
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save vicalloy/7225cf8749e427882e0e70138353739a to your computer and use it in GitHub Desktop.
Save vicalloy/7225cf8749e427882e0e70138353739a to your computer and use it in GitHub Desktop.
money
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