{ "metadata": { "name": "", "signature": "sha256:c9e8d3ae711b549af44eebce872633beb2aff4aed47d8dc35b3e3a6c168195ed" }, "nbformat": 3, "nbformat_minor": 0, "worksheets": [ { "cells": [ { "cell_type": "code", "collapsed": false, "input": [ "import time\n", "start = time.time()\n", "\n", "palindromes = [x*y for x in xrange(100,1000)\n", " for y in xrange(x,1000)\n", " if str(x*y)[::-1]==str(x*y)]\n", "\n", "print \"Answer:{}\".format( max(palindromes) )\n", "print \"Elapsed time:{0} seconds\".format(time.time()-start)" ], "language": "python", "metadata": {}, "outputs": [ { "output_type": "stream", "stream": "stdout", "text": [ "Answer:906609\n", "Elapsed time:0.334797143936 seconds\n" ] } ], "prompt_number": 1 }, { "cell_type": "code", "collapsed": false, "input": [], "language": "python", "metadata": {}, "outputs": [], "prompt_number": 1 }, { "cell_type": "code", "collapsed": false, "input": [], "language": "python", "metadata": {}, "outputs": [], "prompt_number": 1 } ], "metadata": {} } ] }