#!/usr/bin/env python
"""Tools for the Project Euler problems in Python"""

import math
import time
import sys

class EulerUtils(object):
    @staticmethod
    def is_prime(number):
        """Returns True is number is prime, False otherwise"""
        # This algorithm checks if the given number can be divided by integers of the form 6k +/- 1
        # see: http://en.wikipedia.org/wiki/Primality_test#Naive_methods
        if number <= 3:
            return number > 1
        if number % 2 == 0 or number % 3 == 0:
            return False
        for i in range(5, int(number ** 0.5) + 1, 6):
            if number % i == 0 or number % (i + 2) == 0:
                return False
        return True

    @staticmethod
    def is_palindrome(number):
        s = str(number)
        N = len(s)
        i = 0
        while s[i] == s[N - i - 1] and i != N/2:
           i += 1
        return i == N/2

    @staticmethod
    def is_palindrome(string):
        return string == string[::-1]

#class isPalindrome(object):
#    def __init__(self, s):
#        N = len(s)
#        i = 0
#        while s[i] == s[N - i - 1] and i != N/2:
#           i += 1
#        self.result = i == N/2
#    def __str__(self):
#        return str(self.result)




if __name__ == '__main__':
    utils = EulerUtils()
    assert utils.is_prime(2) == True
    assert utils.is_prime(10) == False
    assert utils.is_palindrome("123") == False
    assert utils.is_palindrome("232") == True
    assert utils.is_palindrome("123456") == False
    assert utils.is_palindrome("623326") == True

@@ -742,149 +742,470 @@
 ome(
-number):%0A        s = str(number)%0A        N = len(s)%0A        i = 0%0A        while s%5Bi%5D == s%5BN - i - 1%5D and i != N/2:%0A           i += 1%0A
+value, method = 0):%0A        if isinstance(value, int) and method == 0:%0A            return str(value) == str(value)%5B::-1%5D%0A%0A        elif isinstance(value, int) and method == 1::%0A            import math%0A            N = int(math.log10(value))+1%0A            for i in xrange( (N/2) ):%0A                first = (value %25 ( 10**(N - i))) / 10**(N-1-i)%0A                last =  value%25(10**(i+1))/(10**i)%0A                if first != last:%0A                    break%0A  
         
 retu
@@ -1204,179 +1204,218 @@
     
+  
 return 
-i == N/2%0A%0A    @staticmethod%0A
+first == last%0A%0A    
     
-d
 e
+li
 f is
-_palindrome(string):%0A        return string == string%5B::-1%5D%0A%0A#class isPalindrome(object):%0A#    def __init__(self, s):%0A#
+instance(value, str) and method == 0:%0A            return value == value%5B::-1%5D%0A%0A        elif isinstance(value, str) and method == 1:%0A            s = str(number)%0A   
         
 N = 
@@ -1406,24 +1406,25 @@
 %0A           
+ 
 N = len(s)%0A#
@@ -1422,17 +1422,20 @@
  len(s)%0A
-#
+    
         
@@ -1440,17 +1440,20 @@
   i = 0%0A
-#
+    
         
@@ -1493,17 +1493,16 @@
 != N/2:%0A
-#
         
@@ -1508,106 +1508,46 @@
     
-i += 1%0A#        self.result = i == N/2%0A#    def __str__(self):%0A#        return str(self.result)%0A%0A%0A
+    i += 1%0A            return i == N/2
 %0A%0Aif
@@ -1664,32 +1664,181 @@
 me(10) == False%0A
+    print utils.is_palindrome(1234)%0A    print utils.is_palindrome(12345)%0A    print utils.is_palindrome(1234321)%0A    print utils.is_palindrome(1221)%0A%0A
     assert utils

check if an integer is palindrome without converting it to string