Personal tools

Euler problems/31 to 40

From HaskellWiki

< Euler problems(Difference between revisions)
Jump to: navigation, search
(fix typo)
([http://projecteuler.net/index.php?section=problems&id=31 Problem 31]: naive doubly recursive solution)
Line 3: Line 3:
  
 
Solution:
 
Solution:
 +
 +
This is the naive doubly recursive solution.  Speed would be greatly improved by use of memoization, dynamic programming, or the closed form.
 
<haskell>
 
<haskell>
problem_31 = undefined
+
problem_31 = pence 200 [1,2,5,10,20,50,100,200]
 +
    where pence 0 _  = 1
 +
          pence n [] = 0
 +
          pence n denominations@(d:ds)
 +
                | n < d    = 0
 +
                | otherwise = pence (n - d) denominations
 +
                              + pence n ds
 
</haskell>
 
</haskell>
  

Revision as of 14:22, 28 March 2007

Contents

1 Problem 31

Investigating combinations of English currency denominations.

Solution:

This is the naive doubly recursive solution. Speed would be greatly improved by use of memoization, dynamic programming, or the closed form.

problem_31 = pence 200 [1,2,5,10,20,50,100,200]
    where pence 0 _  = 1
          pence n [] = 0
          pence n denominations@(d:ds)
                | n < d     = 0
                | otherwise = pence (n - d) denominations
                              + pence n ds

2 Problem 32

Find the sum of all numbers that can be written as pandigital products.

Solution:

problem_32 = undefined

3 Problem 33

Discover all the fractions with an unorthodox cancelling method.

Solution:

problem_33 = undefined

4 Problem 34

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

Solution:

problem_34 = undefined

5 Problem 35

How many circular primes are there below one million?

Solution:

problem_35 = undefined

6 Problem 36

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

Solution:

problem_36 = undefined

7 Problem 37

Find the sum of all eleven primes that are both truncatable from left to right and right to left.

Solution:

problem_37 = undefined

8 Problem 38

What is the largest 1 to 9 pandigital that can be formed by multiplying a fixed number by 1, 2, 3, ... ?

Solution:

problem_38 = undefined

9 Problem 39

If p is the perimeter of a right angle triangle, {a, b, c}, which value, for p ≤ 1000, has the most solutions?

Solution:

problem_39 = undefined

10 Problem 40

Finding the nth digit of the fractional part of the irrational number.

Solution:

problem_40 = undefined