Created
March 3, 2017 09:04
-
-
Save danieldiekmeier/63f1f3eaedac011035ff79fa80b7eeb5 to your computer and use it in GitHub Desktop.
Cody's Jams: https://www.acmicpc.net/problem/12034
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
prices = [9, 9, 12, 12, 12, 15, 16, 20] | |
new_prices = [] | |
# The lowest price has to be a reduces price | |
# Then calculate the original price from that | |
# remove both from the prices list and do it again | |
def solve (prices, new_prices): | |
if len(prices) == 0: | |
return new_prices | |
lower = prices.pop(0) | |
higher = lower * (4/3) | |
index = prices.index(higher) | |
prices.pop(index) | |
new_prices.append(lower) | |
return solve(prices, new_prices) | |
print(solve(prices, new_prices)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment