Euler project 4(Python 0.018538s)
昔書いたけど糞コードだったので。
#-*- coding:utf-8 -*- from datetime import datetime def Pali_judge(x): x = list(str(x)) length = len(x) right = x[:length/2] if length % 2 == 1: left = x[ length/2 + 1:] else: left = x[ length/2: ] left = left[::-1] if right == left: return True else: return False def Euler4(): max = 0 for i in xrange(900,1000): for j in xrange(i, 1000): term = i * j if Pali_judge(term) == True: if max < term: max = term return max def main(): start = datetime.now() answer = Euler4() end = datetime.now() print end - start, answer if __name__ == "__main__": main()