# Euler problems/161 to 170

### From HaskellWiki

< Euler problems(Difference between revisions)

Marypoppins (Talk | contribs) |
CaleGibbard (Talk | contribs) (rv: vandalism) |
||

Line 1: | Line 1: | ||

− | Do them on your own! |
+ | == [http://projecteuler.net/index.php?section=problems&id=161 Problem 161] == |

+ | Triominoes |
||

+ | |||

+ | Solution: |
||

+ | <haskell> |
||

+ | problem_161 = undefined |
||

+ | </haskell> |
||

+ | |||

+ | == [http://projecteuler.net/index.php?section=problems&id=162 Problem 162] == |
||

+ | Hexadecimal numbers |
||

+ | |||

+ | Solution: |
||

+ | <haskell> |
||

+ | problem_162 = undefined |
||

+ | </haskell> |
||

+ | |||

+ | == [http://projecteuler.net/index.php?section=problems&id=163 Problem 163] == |
||

+ | Cross-hatched triangles |
||

+ | |||

+ | Solution: |
||

+ | <haskell> |
||

+ | problem_163 = undefined |
||

+ | </haskell> |
||

+ | |||

+ | == [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. |
||

+ | |||

+ | Solution: |
||

+ | <haskell> |
||

+ | 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]] |
||

+ | </haskell> |
||

+ | |||

+ | == [http://projecteuler.net/index.php?section=problems&id=165 Problem 165] == |
||

+ | Intersections |
||

+ | |||

+ | Solution: |
||

+ | <haskell> |
||

+ | problem_165 = undefined |
||

+ | </haskell> |
||

+ | |||

+ | == [http://projecteuler.net/index.php?section=problems&id=166 Problem 166] == |
||

+ | Criss Cross |
||

+ | |||

+ | Solution: |
||

+ | <haskell> |
||

+ | 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 |
||

+ | </haskell> |
||

+ | |||

+ | == [http://projecteuler.net/index.php?section=problems&id=167 Problem 167] == |
||

+ | Investigating Ulam sequences |
||

+ | |||

+ | Solution: |
||

+ | <haskell> |
||

+ | problem_167 = undefined |
||

+ | </haskell> |
||

+ | |||

+ | == [http://projecteuler.net/index.php?section=problems&id=168 Problem 168] == |
||

+ | Number Rotations |
||

+ | |||

+ | Solution: |
||

+ | <haskell> |
||

+ | problem_168 = undefined |
||

+ | </haskell> |
||

+ | |||

+ | == [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. |
||

+ | |||

+ | Solution: |
||

+ | <haskell> |
||

+ | problem_169 = undefined |
||

+ | </haskell> |
||

+ | |||

+ | == [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. |
||

+ | |||

+ | Solution: |
||

+ | <haskell> |
||

+ | problem_170 = undefined |
||

+ | </haskell> |

## Revision as of 04:59, 30 January 2008

## Contents |

## 1 Problem 161

Triominoes

Solution:

problem_161 = undefined

## 2 Problem 162

Hexadecimal numbers

Solution:

problem_162 = undefined

## 3 Problem 163

Cross-hatched triangles

Solution:

problem_163 = undefined

## 4 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]]

## 5 Problem 165

Intersections

Solution:

problem_165 = undefined

## 6 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

## 7 Problem 167

Investigating Ulam sequences

Solution:

problem_167 = undefined

## 8 Problem 168

Number Rotations

Solution:

problem_168 = undefined

## 9 Problem 169

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

Solution:

problem_169 = undefined

## 10 Problem 170

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

Solution:

problem_170 = undefined