{ "metadata": { "name": "hw.2" }, "nbformat": 3, "nbformat_minor": 0, "worksheets": [ { "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "# \u641c\u7d22ZOJ\u8ddf\u77e9\u9635\u76f8\u5173\u7684\u9898\u76ee\n", "\n", "## \u8981\u6c42\n", "\n", "* \u5728[ZOJ](http://acm.zju.edu.cn/onlinejudge/)\u7684[\u9898\u76ee\u5217\u8868](http://acm.zju.edu.cn/onlinejudge/showProblemsets.do)\u4e2d\u641c\u7d22\u6240\u6709\u5305\u542b\u5173\u952e\u5b57\"matrix\"\u6216\"Matrix\"\u6216\"matrices\"\u6216\"Matrices\"\u7684\u9898\u76ee.\n", "* \u5168\u6587\u641c\u7d22.\n", "\n", "## \u63d0\u793a\n", "\n", "* \u53c2\u8003\u641c\u7d22CC98\u7684\u4f8b\u5b50.\n", "* \u4f7f\u7528[set](http://docs.python.org/2/tutorial/datastructures.html#sets)\u53bb\u9664\u91cd\u590d\u94fe\u63a5.\n", "* \u8bd5\u8bd5 `print '[Mm]atrix' or '[Mm]atrices'`\n", "* [if x is false, then y, else x](http://docs.python.org/2/library/stdtypes.html#boolean-operations-and-or-not)\n", "* \u5df2\u7ecf\u63d0\u793a\u5230\u8fd9\u4e2a\u4efd\u4e0a\u4e86 - -" ] }, { "cell_type": "code", "collapsed": false, "input": [ "import re\n", "\n", "for s in ('matrix', 'Matrix', 'matrics', 'Matrics'):\n", " print re.match(r'[mM]atrix|[mM]atrics', s) is not None" ], "language": "python", "metadata": {}, "outputs": [ { "output_type": "stream", "stream": "stdout", "text": [ "True\n", "True\n", "True\n", "True\n" ] } ], "prompt_number": 1 } ], "metadata": {} } ] }