Difference between revisions of "Euler problems/161 to 170"

From HaskellWiki
Jump to navigation Jump to search
(rv: vandalism)
(add problem_169)
Line 86: Line 86:
 
Solution:
 
Solution:
 
<haskell>
 
<haskell>
  +
fusc' 0=(1,0)
problem_169 = undefined
 
  +
fusc' n
  +
|even n=(a+b, b)
  +
|odd n=(a,a+b)
  +
where
  +
(a,b)=fusc' $div n 2
  +
fusc =fst.fusc'
 
problem_169=fusc (10^25)
 
</haskell>
 
</haskell>
   

Revision as of 13:23, 30 January 2008

Problem 161

Triominoes

Solution:

problem_161 = undefined

Problem 162

Hexadecimal numbers

Solution:

problem_162 = undefined

Problem 163

Cross-hatched triangles

Solution:

problem_163 = undefined

Problem 164

Numbers for which no three consecutive digits have a sum greater than a given value.

Solution:

addDigit x = [[sum [x !! b !! c | c <- [0..9-a-b]] | b <- [0..9-a]] | a<-[0..9]]
x3 = [[10-a-b | b <- [0..9-a]] | a <- [0..9]]
x20 = iterate addDigit x3 !! 17
problem_164 = sum [x20 !! a !! b | a <- [1..9], b <- [0..9-a]]

Problem 165

Intersections

Solution:

problem_165 = undefined

Problem 166

Criss Cross

Solution:

problem_166 = 
    sum [ product (map count [[0, c, b-d, a-b-d], 
            [0, b-a, c+d-a, b+d-a], 
            [0, -b-c, a-b-c-d, -c-d],
            [0, a, d, c+d]])|
        a <- [-9..9], 
        b <- [-9+a..9+a],
        c <- [-9..9],
        d <- [-9+a-c..9+a-c]]
    where
    count xs 
        |u<l=0 
        |otherwise=u-l+1
        where
        l = -minimum xs 
        u = 9-maximum xs

Problem 167

Investigating Ulam sequences

Solution:

problem_167 = undefined

Problem 168

Number Rotations

Solution:

problem_168 = undefined

Problem 169

Exploring the number of different ways a number can be expressed as a sum of powers of 2.

Solution:

fusc' 0=(1,0)
fusc' n
    |even n=(a+b, b)
    |odd n=(a,a+b)
    where
    (a,b)=fusc' $div n 2
fusc =fst.fusc'
problem_169=fusc (10^25)

Problem 170

Find the largest 0 to 9 pandigital that can be formed by concatenating products.

Solution:

problem_170 = undefined