Euler problems/91 to 100
Revision as of 15:08, 30 August 2007
Find the number of right angle triangles in the quadrant.
problem_91 = undefined
Investigating a square digits number chain with a surprising property.
problem_92 = undefined
Using four distinct digits and the rules of arithmetic, find the longest sequence of target numbers.
problem_93 = undefined
Investigating almost equilateral triangles with integral sides and area.
problem_94 = undefined
Find the smallest member of the longest amicable chain with no element exceeding one million.
Solution which avoid visiting a number more than one time :
import Data.Array.Unboxed import qualified Data.IntSet as S import Data.List takeUntil _  =  takeUntil pred (x:xs) = x : if pred x then takeUntil pred xs else  chain n s = lgo [n] $ properDivisorsSum ! n where lgo xs x | x > 1000000 || S.notMember x s = (xs,) | x `elem` xs = (xs,x : takeUntil (/= x) xs) | otherwise = lgo (x:xs) $ properDivisorsSum ! x properDivisorsSum :: UArray Int Int properDivisorsSum = accumArray (+) 1 (0,1000000) $ (0,-1):[(k,factor)| factor<-[2..1000000 `div` 2] , k<-[2*factor,2*factor+factor..1000000] ] base = S.fromList [1..1000000] problem_95 = fst $ until (S.null . snd) f ((0,0),base) where f (p@(n,m), s) = (p', s') where setMin = head $ S.toAscList s (explored, chn) = chain setMin s len = length chn p' = if len > m then (minimum chn, len) else p s' = foldl' (flip S.delete) s explored
Devise an algorithm for solving Su Doku puzzles.
problem_96 = undefined
Find the last ten digits of the non-Mersenne prime: 28433 × 27830457 + 1.
problem_97 = (28433 * 2^7830457 + 1) `mod` (10^10)
Investigating words, and their anagrams, which can represent square numbers.
problem_98 = undefined
Which base/exponent pair in the file has the greatest numerical value?
problem_99 = undefined
10 Problem 100
Finding the number of blue discs for which there is 50% chance of taking two blue.
problem_100 = undefined