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

From HaskellWiki
Jump to navigation Jump to search
(Added solution for problem 166)
Line 1: Line 1:
== [http://projecteuler.net/index.php?section=view&id=161 Problem 161] ==
+
== [http://projecteuler.net/index.php?section=problems&id=161 Problem 161] ==
 
Triominoes
 
Triominoes
   
Line 7: Line 7:
 
</haskell>
 
</haskell>
   
== [http://projecteuler.net/index.php?section=view&id=162 Problem 162] ==
+
== [http://projecteuler.net/index.php?section=problems&id=162 Problem 162] ==
 
Hexadecimal numbers
 
Hexadecimal numbers
   
Line 15: Line 15:
 
</haskell>
 
</haskell>
   
== [http://projecteuler.net/index.php?section=view&id=163 Problem 163] ==
+
== [http://projecteuler.net/index.php?section=problems&id=163 Problem 163] ==
 
Cross-hatched triangles
 
Cross-hatched triangles
   
Line 23: Line 23:
 
</haskell>
 
</haskell>
   
== [http://projecteuler.net/index.php?section=view&id=164 Problem 164] ==
+
== [http://projecteuler.net/index.php?section=problems&id=164 Problem 164] ==
 
Numbers for which no three consecutive digits have a sum greater than a given value.
 
Numbers for which no three consecutive digits have a sum greater than a given value.
   
Line 34: Line 34:
 
</haskell>
 
</haskell>
   
== [http://projecteuler.net/index.php?section=view&id=165 Problem 165] ==
+
== [http://projecteuler.net/index.php?section=problems&id=165 Problem 165] ==
 
Intersections
 
Intersections
   
Line 42: Line 42:
 
</haskell>
 
</haskell>
   
== [http://projecteuler.net/index.php?section=view&id=166 Problem 166] ==
+
== [http://projecteuler.net/index.php?section=problems&id=166 Problem 166] ==
 
Criss Cross
 
Criss Cross
   
Line 65: Line 65:
 
</haskell>
 
</haskell>
   
== [http://projecteuler.net/index.php?section=view&id=167 Problem 167] ==
+
== [http://projecteuler.net/index.php?section=problems&id=167 Problem 167] ==
 
Investigating Ulam sequences
 
Investigating Ulam sequences
   
Line 73: Line 73:
 
</haskell>
 
</haskell>
   
== [http://projecteuler.net/index.php?section=view&id=168 Problem 168] ==
+
== [http://projecteuler.net/index.php?section=problems&id=168 Problem 168] ==
 
Number Rotations
 
Number Rotations
   
Line 81: Line 81:
 
</haskell>
 
</haskell>
   
== [http://projecteuler.net/index.php?section=view&id=169 Problem 169] ==
+
== [http://projecteuler.net/index.php?section=problems&id=169 Problem 169] ==
 
Exploring the number of different ways a number can be expressed as a sum of powers of 2.
 
Exploring the number of different ways a number can be expressed as a sum of powers of 2.
   
Line 89: Line 89:
 
</haskell>
 
</haskell>
   
== [http://projecteuler.net/index.php?section=view&id=170 Problem 170] ==
+
== [http://projecteuler.net/index.php?section=problems&id=170 Problem 170] ==
 
Find the largest 0 to 9 pandigital that can be formed by concatenating products.
 
Find the largest 0 to 9 pandigital that can be formed by concatenating products.
   

Revision as of 13:55, 22 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:

problem_169 = undefined

Problem 170

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

Solution:

problem_170 = undefined