Last active
May 19, 2017 08:52
-
-
Save btseytlin/e890719da3c317cedd1709284247d0c7 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
import sys | |
def get_operations(diff, cookies): | |
operations = 0 | |
for i, c in enumerate(cookies): | |
x = cookies[i]-diff | |
while x > 0: | |
operations+= x // 5 | |
x = x % 5 | |
operations+= x // 2 | |
x = x % 2 | |
operations+= x // 1 | |
x = x % 1 | |
return operations | |
def equalize(cookies): | |
min_cookies = min(cookies) | |
cookie_diff = [x-min_cookies for x in cookies] | |
diffs = [min_cookies-i for i in range(5)] | |
operations = [get_operations(diff, cookies) for diff in diffs] | |
return min(operations) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment