{ "metadata": { "name": "" }, "nbformat": 3, "nbformat_minor": 0, "worksheets": [ { "cells": [ { "cell_type": "markdown", "source": [ "A palindromic number reads the same both ways. The largest palindrome made from the product of two 2-digit numbers is 9009 = 91 \u00d7 99.\n", "\n", "Find the largest palindrome made from the product of two 3-digit numbers." ] }, { "cell_type": "code", "collapsed": false, "input": [ "class Integer\n", " def palindromic?\n", " self.to_s == self.to_s.reverse\n", " end\n", "end\n", "\n", "12321.palindromic?" ], "language": "python", "outputs": [ { "output_type": "pyout", "prompt_number": 4, "text": [ "true" ] } ], "prompt_number": 4 }, { "cell_type": "code", "collapsed": false, "input": [ "result = []\n", "\n", "(111..999).lazy.each do |x|\n", " (111...999).lazy.each do |y|\n", " temp = x * y\n", " result << temp if temp.palindromic?\n", " end\n", "end\n", "\n", "result.max" ], "language": "python", "outputs": [ { "output_type": "pyout", "prompt_number": 8, "text": [ "906609" ] } ], "prompt_number": 8 } ] } ] }