Created
November 28, 2011 16:54
-
-
Save dmalikov/1401073 to your computer and use it in GitHub Desktop.
Project Euler 206 (1 s)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Data.List (find) | |
import Control.Monad (replicateM) | |
import Data.Maybe (fromJust) | |
import Numeric (showFFloat) | |
isSquare :: Integer -> Bool | |
isSquare x = x'*x' == x | |
where x' = truncate $ sqrt (fromIntegral x :: Double) | |
sew :: [Integer] -> Integer | |
sew = foldl1 ((+).(*10)) . (++ [9,0,0]) . concatMap (uncurry ((. return) . (:))) . zip [1..] | |
main = print $ showFFloat (Just 0) (sqrt . fromIntegral . fromJust . find isSquare . map sew $ replicateM 8 [9,8..0]) "" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment