Euler problems/111 to 120
Search for 10-digit primes containing the maximum number of repeated digits.
import Control.Monad (replicateM) -- All ways of interspersing n copies of x into a list intr :: Int -> a -> [a] -> [[a]] intr 0 _ y = [y] intr n x (y:ys) = concat [map ((replicate i x ++) . (y :)) $ intr (n-i) x ys | i <- [0..n]] intr n x _ = [replicate n x] -- All 10-digit primes containing the maximal number of the digit d maxDigits :: Char -> [Integer] maxDigits d = head $ dropWhile null [filter isPrime $ map read $ filter ((/='0') . head) $ concatMap (intr (10-n) d) $ replicateM n $ delete d "0123456789" | n <- [1..9]] problem_111 = sum $ concatMap maxDigits "0123456789"
Investigating the density of "bouncy" numbers.
problem_112 = undefined
How many numbers below a googol (10100) are not "bouncy"?
import Array mkArray b f = listArray b $ map f (range b) digits = 100 inc = mkArray ((1, 0), (digits, 9)) ninc dec = mkArray ((1, 0), (digits, 9)) ndec ninc (1, _) = 1 ninc (l, d) = sum [inc ! (l-1, i) | i <- [d..9]] ndec (1, _) = 1 ndec (l, d) = sum [dec ! (l-1, i) | i <- [0..d]] problem_113 = sum [inc ! i | i <- range ((digits, 0), (digits, 9))] + sum [dec ! i | i <- range ((1, 1), (digits, 9))] - digits*9 -- numbers like 11111 are counted in both inc and dec - 1 -- 0 is included in the increasing numbers
Note: inc and dec contain the same data, but it seems clearer to duplicate them.
Investigating the number of ways to fill a row with separated blocks that are at least three units long.
problem_114 = undefined
Finding a generalisation for the number of ways to fill a row with separated blocks.
problem_115 = undefined
Investigating the number of ways of replacing square tiles with one of three coloured tiles.
problem_116 = undefined
Investigating the number of ways of tiling a row using different-sized tiles.
problem_117 = undefined
Exploring the number of ways in which sets containing prime elements can be made.
problem_118 = undefined
Investigating the numbers which are equal to sum of their digits raised to some power.
problem_119 = undefined
Finding the maximum remainder when (a − 1)n + (a + 1)n is divided by a2.
problem_120 = undefined