Last active
September 3, 2015 09:50
-
-
Save mauritsvdvijgh/e78aeb4239f9f6741cb5 to your computer and use it in GitHub Desktop.
Vraag 15 Tweakers Devv Answer Contest
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 itertools | |
| ''' | |
| 4 * € 2,- | |
| 2 * € 1,- | |
| 8 * € 0,50 | |
| 1 * € 0,20 | |
| 4 * € 0,10 | |
| 3 * € 0,05 | |
| Hoeveel unieke bedragen kun je maken met min. 1 en max. 5 munten? | |
| ''' | |
| # coins is een lijst met munten (gedeeld door 0.05 dus 0.05 is 1 en 0.50 is 10) | |
| coins, sum_list = [1,1,1,2,2,2,2,4,10,10,10,10,10,10,10,10,20,20,40,40,40,40], [] | |
| for number in range(1,6): | |
| for combination in list(itertools.combinations(coins, number)): | |
| sum = 0 | |
| for coin in combination: | |
| sum += coin | |
| if sum not in sum_list: | |
| sum_list.append(sum) | |
| print len(sum_list) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment