Initial commit
This commit is contained in:
38
problem-31.py
Normal file
38
problem-31.py
Normal file
@@ -0,0 +1,38 @@
|
||||
|
||||
import itertools
|
||||
|
||||
pence = list(range(201))
|
||||
two_pence = list(range(101))
|
||||
five_pence = list(range(41))
|
||||
ten_pence = list(range(21))
|
||||
twenty_pence = list(range(11))
|
||||
fifty_pence = list(range(5))
|
||||
pound = [0, 1, 2]
|
||||
two_pound = [0, 1]
|
||||
|
||||
results = []
|
||||
combos = itertools.product(
|
||||
pence,
|
||||
two_pence,
|
||||
five_pence,
|
||||
ten_pence,
|
||||
twenty_pence,
|
||||
fifty_pence,
|
||||
pound,
|
||||
# two_pound
|
||||
)
|
||||
|
||||
for combo in combos:
|
||||
if combo[0] \
|
||||
+ combo[1] * 2 \
|
||||
+ combo[2] * 5 \
|
||||
+ combo[3] * 10 \
|
||||
+ combo[4] * 20 \
|
||||
+ combo[5] * 50 \
|
||||
+ combo[6] * 100 == 200:
|
||||
results.append(combo)
|
||||
|
||||
results.append((0, 0, 0, 0, 0, 0)) # representing 1 pound coin
|
||||
|
||||
print(results)
|
||||
print(len(results))
|
||||
Reference in New Issue
Block a user