Q031

Coin sums

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?


In [ ]:
import numpy as np
coins=np.array([1,2,5,10,20,50,100,200])
n=200
max_coins=n/coins
mc=max_coins
c=coins

import itertools
for element in itertools.product(np.arange(mc[0]+1),np.arange(mc[1]+1),np.arange(mc[2]+1),np.arange(mc[3]+1),np.arange(mc[4]+1),np.arange(mc[5]+1),np.arange(mc[6]+1),np.arange(mc[7]+1)):
    if np.dot(element,c) == n:
         count+=1
print count

Q032

Pandigital products

We shall say that an n-digit number is pandigital if it makes use of all the digits 1 to n exactly once; for example, the 5-digit number, 15234, is 1 through 5 pandigital.

The product 7254 is unusual, as the identity, 39 × 186 = 7254, containing multiplicand, multiplier, and product is 1 through 9 pandigital.

Find the sum of all products whose multiplicand/multiplier/product identity can be written as a 1 through 9 pandigital.

HINT: Some products can be obtained in more than one way so be sure to only include it once in your sum.


In [ ]:

Q033

Digit cancelling fractions

The fraction 49/98 is a curious fraction, as an inexperienced mathematician in attempting to simplify it may incorrectly believe that 49/98 = 4/8, which is correct, is obtained by cancelling the 9s.

We shall consider fractions like, 30/50 = 3/5, to be trivial examples.

There are exactly four non-trivial examples of this type of fraction, less than one in value, and containing two digits in the numerator and denominator.

If the product of these four fractions is given in its lowest common terms, find the value of the denominator.


In [ ]:

Q034

Digit factorials

145 is a curious number, as 1! + 4! + 5! = 1 + 24 + 120 = 145.

Find the sum of all numbers which are equal to the sum of the factorial of their digits.

Note: as 1! = 1 and 2! = 2 are not sums they are not included.


In [5]:
import math
math.factorial(7)


Out[5]:
5040

Q036

Double-base palindromes

The decimal number, 585 = 10010010012 (binary), is palindromic in both bases.

Find the sum of all numbers, less than one million, which are palindromic in base 10 and base 2.

(Please note that the palindromic number, in either base, may not include leading zeros.)


In [3]:
i=1
sum=0
while i < 1e6:
    if str(i)[::-1] == str(i):
        b="{0:b}".format(i)
        if b == b[::-1]:
            sum+=i
    i+=1
print sum


872187

In [ ]: