Blame view

4.py 566 Bytes
Imanol-Mikel Barba Sabariego authored
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
#!/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);