Created
November 1, 2009 22:32
-
-
Save jlouis/223763 to your computer and use it in GitHub Desktop.
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 | |
numbers = [1..10^6] | |
convRadix :: (Integral b) => b -> b -> [b] | |
convRadix n = | |
unfoldr (\b -> if b == 0 then Nothing else Just (b `mod` n, b `div` n)) | |
isPalindrome10 n = sn == (reverse sn) | |
where sn = show n | |
isPalindrome2 n = sn == (reverse sn) | |
where sn = concatMap show $ convRadix 2 n | |
check ns = sum $ filter (\n -> isPalindrome10 n && isPalindrome2 n) ns | |
main = | |
do putStrLn $ show $ check numbers | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment