4.py
566 Bytes
#!/usr/bin/python
import sys;
def isPalindrome(num):
strNum = str(num);
strNumRev = "";
for x in range (len(strNum),0,-1):
strNumRev += strNum[x-1];
numRev = int(strNumRev);
if(numRev == num):
return True;
return False;
cipherLength = int(sys.argv[1]);
higherPalindrome = -1;
for i in range (1*(10**(cipherLength-1)),1*(10**cipherLength)):
for j in range (1*(10**(cipherLength-1)),1*(10**cipherLength)):
num = i*j;
if(isPalindrome(num)):
if(num > higherPalindrome):
higherPalindrome = num;
print "Result is: " + str(higherPalindrome);