Created
August 18, 2020 00:21
-
-
Save EricGustin/9c15f7666fa53a7d612b4580f5a13b4c to your computer and use it in GitHub Desktop.
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
| 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