module Problem36 where

import Palindrome

main :: IO ()
main = print . sum . filter isPalindromicBoth $ [1 .. 1000000]

isPalindromicBoth :: Int -> Bool
isPalindromicBoth n = isPalindromeInt n && (isPalindromeString . toBinary $ n)

toBinary :: Int -> String
toBinary 1 = "1"
toBinary 0 = "0"
toBinary n = toBinary (n `div` 2) ++ toBinary (n `mod` 2)
