Skip to content

Problem 36

May 30, 2010

Below, one can find my solution to the 36th Euler problem:

import Numeric
import Char
import List

f i = isPalindrome (show i) && isPalindrome (showIntAtBase 2 intToDigit i "")
  where isPalindrome l = l == reverse l

main = print $ sum [i | i <- [1..10^6], f i]

GHC’s execution time was good enough:

real 0m0.175s
user 0m0.171s
sys 0m0.003s
Advertisements
Leave a Comment

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: