Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #In England the currency is made up of pound, £, and pence, p, and there are
- #eight coins in general circulation:
- # 1p, 2p, 5p, 10p, 20p, 50p, £1 (100p) and £2 (200p).
- #It is possible to make £2 in the following way:
- # 1×£1 + 1×50p + 2×20p + 1×5p + 1×2p + 3×1p
- #How many different ways can £2 be made using any number of coins?
- count = 0
- for a in range(2):
- if (200*a) > 200:
- break
- for b in range(3):
- if (200*a + 100*b) > 200:
- break
- for c in range(5):
- if (200*a + 100*b + 50*c) > 200:
- break
- for d in range(11):
- if (200*a + 100*b + 50*c + 20*d) > 200:
- break
- for e in range(21):
- if (200*a + 100*b + 50*c + 20*d + 10*e) > 200:
- break
- for f in range(41):
- if (200*a + 100*b + 50*c + 20*d + 10*e + 5*f) > 200:
- break
- for g in range(101):
- if (200*a + 100*b + 50*c + 20*d + 10*e + 5*f
- + 2*g) > 200:
- break
- for h in range(201):
- if (200*a + 100*b + 50*c + 20*d +
- 10*e + 5*f + 2*g + 1*h) > 200:
- count += 1
- break
- print count
Advertisement
Add Comment
Please, Sign In to add comment