Skip to content

Instantly share code, notes, and snippets.

@EricGustin
Created August 18, 2020 00:21
Show Gist options
  • Select an option

  • Save EricGustin/9c15f7666fa53a7d612b4580f5a13b4c to your computer and use it in GitHub Desktop.

Select an option

Save EricGustin/9c15f7666fa53a7d612b4580f5a13b4c to your computer and use it in GitHub Desktop.
def distributeItems(items: int, n: int):
itemsPerTurn = []
j = 0 # current turn
numOfItems = n*(n+1)//2 # number of items given during turn 0
while items >= numOfItems:
items -= numOfItems
itemsPerTurn.append(numOfItems)
j += 1
numOfItems = n**2 * j + n*(n+1)//2 # number of items given during turn j
return itemsPerTurn
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment