{
"metadata": {
"name": "",
- "signature": "sha256:a4f2510e4612d8ec6693f09edf9acc836f64b1078feac9000ff71e3ea775ee2f"
+ "signature": "sha256:78e6a962b2bb32da5900535436f656d194701924a6f32591d57f2b5973eb315c"
},
"nbformat": 3,
"nbformat_minor": 0,
"worksheets": [
{
"cells": [
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "import string\n",
+ "string.ascii_lowercase"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "metadata": {},
+ "output_type": "pyout",
+ "prompt_number": 1,
+ "text": [
+ "'abcdefghijklmnopqrstuvwxyz'"
+ ]
+ }
+ ],
+ "prompt_number": 1
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "string.ascii_lowercase[:-2]"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "metadata": {},
+ "output_type": "pyout",
+ "prompt_number": 9,
+ "text": [
+ "'abcdefghijklmnopqrstuvwx'"
+ ]
+ }
+ ],
+ "prompt_number": 9
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "for i in range(10):\n",
+ " print(i, string.ascii_lowercase[i+2].upper())"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "0 C\n",
+ "1 D\n",
+ "2 E\n",
+ "3 F\n",
+ "4 G\n",
+ "5 H\n",
+ "6 I\n",
+ "7 J\n",
+ "8 K\n",
+ "9 L\n"
+ ]
+ }
+ ],
+ "prompt_number": 14
+ },
{
"cell_type": "code",
"collapsed": false,
],
"prompt_number": 1
},
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "members = ['Freddie', 'Brian', 'Roger', 'John']\n",
+ "members = ['Paul'] + members"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [],
+ "prompt_number": 20
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "members[99]"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "ename": "IndexError",
+ "evalue": "list index out of range",
+ "output_type": "pyerr",
+ "traceback": [
+ "\u001b[1;31m---------------------------------------------------------------------------\u001b[0m\n\u001b[1;31mIndexError\u001b[0m Traceback (most recent call last)",
+ "\u001b[1;32m<ipython-input-22-6b5bb11d700b>\u001b[0m in \u001b[0;36m<module>\u001b[1;34m()\u001b[0m\n\u001b[1;32m----> 1\u001b[1;33m \u001b[0mmembers\u001b[0m\u001b[1;33m[\u001b[0m\u001b[1;36m99\u001b[0m\u001b[1;33m]\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0m",
+ "\u001b[1;31mIndexError\u001b[0m: list index out of range"
+ ]
+ }
+ ],
+ "prompt_number": 22
+ },
{
"cell_type": "code",
"collapsed": false,
],
"prompt_number": 18
},
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "l2 = []\n",
+ "for i in (2,4,8,22):\n",
+ " l2 += [i]\n",
+ "l2"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "metadata": {},
+ "output_type": "pyout",
+ "prompt_number": 25,
+ "text": [
+ "[2, 4, 8, 22]"
+ ]
+ }
+ ],
+ "prompt_number": 25
+ },
{
"cell_type": "code",
"collapsed": false,
"language": "python",
"metadata": {},
"outputs": [],
- "prompt_number": 22
+ "prompt_number": 26
},
{
"cell_type": "code",
"collapsed": false,
"input": [
- "grid_nums = [int(n) for n in GRID_STRING.split()]\n",
- "grid_nums"
+ "gt= {}\n",
+ "for x in range(COLUMNS):\n",
+ " for y in range(ROWS):\n",
+ " gt[(x,y)] = grid_nums[x + y * COLUMNS]\n",
+ "gt"
],
"language": "python",
"metadata": {},
{
"metadata": {},
"output_type": "pyout",
- "prompt_number": 21,
+ "prompt_number": 41,
"text": [
- "[8,\n",
- " 2,\n",
- " 22,\n",
- " 97,\n",
- " 38,\n",
- " 15,\n",
- " 0,\n",
- " 40,\n",
- " 0,\n",
- " 75,\n",
- " 4,\n",
- " 5,\n",
- " 7,\n",
- " 78,\n",
- " 52,\n",
- " 12,\n",
- " 50,\n",
- " 77,\n",
- " 91,\n",
- " 8,\n",
- " 49,\n",
- " 49,\n",
- " 99,\n",
- " 40,\n",
- " 17,\n",
- " 81,\n",
- " 18,\n",
- " 57,\n",
- " 60,\n",
- " 87,\n",
- " 17,\n",
- " 40,\n",
- " 98,\n",
- " 43,\n",
- " 69,\n",
- " 48,\n",
- " 4,\n",
- " 56,\n",
- " 62,\n",
- " 0,\n",
- " 81,\n",
- " 49,\n",
- " 31,\n",
- " 73,\n",
- " 55,\n",
- " 79,\n",
- " 14,\n",
- " 29,\n",
- " 93,\n",
- " 71,\n",
- " 40,\n",
- " 67,\n",
- " 53,\n",
- " 88,\n",
- " 30,\n",
- " 3,\n",
- " 49,\n",
- " 13,\n",
- " 36,\n",
- " 65,\n",
- " 52,\n",
- " 70,\n",
- " 95,\n",
- " 23,\n",
- " 4,\n",
- " 60,\n",
- " 11,\n",
- " 42,\n",
- " 69,\n",
- " 24,\n",
- " 68,\n",
- " 56,\n",
- " 1,\n",
- " 32,\n",
- " 56,\n",
- " 71,\n",
- " 37,\n",
- " 2,\n",
- " 36,\n",
- " 91,\n",
- " 22,\n",
- " 31,\n",
- " 16,\n",
- " 71,\n",
- " 51,\n",
- " 67,\n",
- " 63,\n",
- " 89,\n",
- " 41,\n",
- " 92,\n",
- " 36,\n",
- " 54,\n",
- " 22,\n",
- " 40,\n",
- " 40,\n",
- " 28,\n",
- " 66,\n",
- " 33,\n",
- " 13,\n",
- " 80,\n",
- " 24,\n",
- " 47,\n",
- " 32,\n",
- " 60,\n",
- " 99,\n",
- " 3,\n",
- " 45,\n",
- " 2,\n",
- " 44,\n",
- " 75,\n",
- " 33,\n",
- " 53,\n",
- " 78,\n",
- " 36,\n",
- " 84,\n",
- " 20,\n",
- " 35,\n",
- " 17,\n",
- " 12,\n",
- " 50,\n",
- " 32,\n",
- " 98,\n",
- " 81,\n",
- " 28,\n",
- " 64,\n",
- " 23,\n",
- " 67,\n",
- " 10,\n",
- " 26,\n",
- " 38,\n",
- " 40,\n",
- " 67,\n",
- " 59,\n",
- " 54,\n",
- " 70,\n",
- " 66,\n",
- " 18,\n",
- " 38,\n",
- " 64,\n",
- " 70,\n",
- " 67,\n",
- " 26,\n",
- " 20,\n",
- " 68,\n",
- " 2,\n",
- " 62,\n",
- " 12,\n",
- " 20,\n",
- " 95,\n",
- " 63,\n",
- " 94,\n",
- " 39,\n",
- " 63,\n",
- " 8,\n",
- " 40,\n",
- " 91,\n",
- " 66,\n",
+ "{(7, 3): 42,\n",
+ " (6, 9): 76,\n",
+ " (17, 11): 29,\n",
+ " (19, 19): 48,\n",
+ " (16, 6): 18,\n",
+ " (7, 12): 7,\n",
+ " (19, 4): 80,\n",
+ " (18, 4): 13,\n",
+ " (18, 19): 67,\n",
+ " (8, 5): 44,\n",
+ " (10, 8): 78,\n",
+ " (9, 0): 75,\n",
+ " (11, 5): 53,\n",
+ " (10, 7): 94,\n",
+ " (14, 18): 81,\n",
+ " (12, 6): 59,\n",
+ " (10, 18): 49,\n",
+ " (0, 17): 20,\n",
+ " (15, 11): 24,\n",
+ " (14, 1): 69,\n",
+ " (13, 7): 8,\n",
+ " (12, 17): 82,\n",
+ " (0, 4): 22,\n",
+ " (15, 4): 28,\n",
+ " (1, 1): 49,\n",
+ " (4, 10): 22,\n",
+ " (3, 2): 73,\n",
+ " (2, 6): 81,\n",
+ " (5, 11): 35,\n",
+ " (4, 5): 99,\n",
+ " (6, 0): 0,\n",
+ " (4, 16): 38,\n",
+ " (7, 5): 2,\n",
+ " (19, 13): 40,\n",
+ " (7, 0): 40,\n",
+ " (16, 19): 89,\n",
+ " (17, 7): 49,\n",
+ " (18, 10): 56,\n",
+ " (17, 18): 57,\n",
+ " (16, 8): 34,\n",
+ " (8, 12): 5,\n",
+ " (9, 9): 45,\n",
+ " (10, 14): 57,\n",
+ " (8, 18): 74,\n",
+ " (11, 15): 67,\n",
+ " (9, 19): 92,\n",
+ " (15, 16): 32,\n",
+ " (14, 8): 14,\n",
+ " (13, 0): 78,\n",
+ " (12, 8): 96,\n",
+ " (11, 16): 18,\n",
+ " (15, 13): 77,\n",
+ " (13, 13): 52,\n",
+ " (2, 18): 35,\n",
+ " (0, 14): 4,\n",
+ " (3, 11): 42,\n",
+ " (2, 1): 99,\n",
+ " (1, 15): 36,\n",
+ " (4, 12): 35,\n",
+ " (2, 12): 0,\n",
+ " (5, 1): 81,\n",
+ " (3, 17): 41,\n",
+ " (16, 7): 66,\n",
+ " (6, 14): 99,\n",
+ " (19, 18): 54,\n",
+ " (17, 6): 38,\n",
+ " (7, 15): 72,\n",
+ " (19, 7): 21,\n",
+ " (18, 5): 12,\n",
+ " (7, 1): 57,\n",
+ " (18, 16): 76,\n",
+ " (8, 6): 26,\n",
+ " (10, 9): 35,\n",
+ " (9, 7): 63,\n",
+ " (11, 4): 54,\n",
+ " (10, 4): 36,\n",
+ " (14, 19): 52,\n",
+ " (12, 7): 63,\n",
+ " (11, 9): 14,\n",
+ " (10, 19): 33,\n",
+ " (0, 18): 20,\n",
+ " (15, 10): 14,\n",
+ " (14, 6): 70,\n",
+ " (13, 6): 54,\n",
+ " (12, 18): 48,\n",
+ " (1, 19): 70,\n",
+ " (0, 5): 24,\n",
+ " (15, 7): 91,\n",
+ " (13, 19): 43,\n",
+ " (1, 0): 2,\n",
+ " (0, 8): 24,\n",
+ " (4, 11): 96,\n",
+ " (3, 5): 60,\n",
+ " (2, 7): 20,\n",
+ " (5, 10): 75,\n",
+ " (4, 6): 64,\n",
+ " (6, 1): 18,\n",
+ " (5, 7): 62,\n",
+ " (4, 17): 72,\n",
+ " (16, 1): 4,\n",
+ " (19, 12): 58,\n",
+ " (17, 12): 54,\n",
+ " (7, 17): 88,\n",
+ " (19, 1): 0,\n",
+ " (18, 11): 85,\n",
+ " (7, 6): 10,\n",
+ " (8, 13): 28,\n",
+ " (9, 8): 17,\n",
+ " (8, 0): 0,\n",
+ " (10, 15): 33,\n",
+ " (8, 19): 16,\n",
+ " (11, 14): 32,\n",
+ " (9, 18): 31,\n",
+ " (15, 19): 1,\n",
+ " (14, 9): 33,\n",
+ " (12, 9): 0,\n",
+ " (11, 19): 48,\n",
+ " (15, 12): 58,\n",
+ " (13, 12): 60,\n",
+ " (2, 19): 54,\n",
+ " (0, 15): 88,\n",
+ " (3, 10): 28,\n",
+ " (1, 14): 52,\n",
+ " (4, 13): 5,\n",
+ " (2, 13): 81,\n",
+ " (5, 0): 15,\n",
+ " (3, 16): 73,\n",
+ " (6, 15): 20,\n",
+ " (16, 9): 34,\n",
+ " (16, 10): 9,\n",
+ " (7, 14): 16,\n",
+ " (6, 18): 90,\n",
+ " (19, 6): 70,\n",
+ " (18, 2): 36,\n",
+ " (17, 10): 53,\n",
+ " (18, 17): 36,\n",
+ " (16, 2): 49,\n",
+ " (8, 7): 95,\n",
+ " (9, 6): 38,\n",
+ " (11, 7): 39,\n",
+ " (10, 5): 33,\n",
+ " (14, 16): 29,\n",
+ " (12, 0): 7,\n",
+ " (11, 8): 78,\n",
+ " (10, 16): 72,\n",
+ " (0, 19): 1,\n",
+ " (14, 7): 40,\n",
+ " (13, 5): 36,\n",
+ " (12, 19): 61,\n",
+ " (1, 18): 73,\n",
+ " (0, 6): 32,\n",
+ " (15, 6): 66,\n",
+ " (13, 18): 86,\n",
+ " (1, 7): 26,\n",
+ " (0, 9): 21,\n",
+ " (3, 4): 71,\n",
+ " (2, 4): 16,\n",
+ " (5, 9): 0,\n",
+ " (4, 7): 2,\n",
+ " (6, 6): 67,\n",
+ " (5, 6): 23,\n",
+ " (4, 18): 78,\n",
+ " (7, 7): 20,\n",
+ " (5, 19): 51,\n",
+ " (19, 15): 69,\n",
+ " (17, 3): 2,\n",
+ " (7, 16): 11,\n",
+ " (19, 0): 8,\n",
+ " (18, 8): 63,\n",
+ " (17, 16): 62,\n",
+ " (7, 4): 89,\n",
+ " (9, 15): 46,\n",
+ " (8, 1): 60,\n",
+ " (10, 12): 44,\n",
+ " (11, 1): 40,\n",
+ " (9, 17): 62,\n",
+ " (15, 18): 16,\n",
+ " (14, 14): 26,\n",
+ " (12, 10): 4,\n",
+ " (11, 18): 71,\n",
+ " (15, 15): 32,\n",
+ " (13, 11): 17,\n",
+ " (2, 16): 16,\n",
+ " (0, 0): 8,\n",
+ " (8, 14): 7,\n",
+ " (1, 13): 80,\n",
+ " (4, 14): 97,\n",
+ " (2, 10): 53,\n",
+ " (5, 15): 62,\n",
+ " (3, 19): 71,\n",
+ " (6, 12): 89,\n",
+ " (17, 4): 33,\n",
+ " (16, 12): 51,\n",
+ " (6, 19): 54,\n",
+ " (19, 9): 95,\n",
+ " (18, 3): 36,\n",
+ " (17, 9): 31,\n",
+ " (18, 14): 98,\n",
+ " (17, 17): 4,\n",
+ " (16, 0): 50,\n",
+ " (16, 15): 63,\n",
+ " (9, 5): 75,\n",
+ " (11, 6): 67,\n",
+ " (10, 2): 40,\n",
+ " (14, 17): 59,\n",
+ " (12, 1): 98,\n",
+ " (11, 11): 24,\n",
+ " (10, 17): 99,\n",
+ " (14, 4): 40,\n",
+ " (13, 4): 40,\n",
+ " (12, 12): 44,\n",
+ " (1, 17): 69,\n",
+ " (0, 7): 67,\n",
+ " (15, 1): 48,\n",
+ " (13, 17): 67,\n",
+ " (1, 6): 98,\n",
+ " (0, 10): 78,\n",
+ " (17, 13): 89,\n",
+ " (3, 7): 68,\n",
+ " (2, 5): 32,\n",
+ " (1, 11): 39,\n",
+ " (5, 8): 73,\n",
+ " (4, 0): 38,\n",
+ " (6, 7): 12,\n",
+ " (5, 5): 3,\n",
+ " (4, 19): 83,\n",
+ " (16, 3): 37,\n",
+ " (6, 10): 31,\n",
+ " (5, 18): 31,\n",
+ " (19, 14): 66,\n",
+ " (17, 2): 13,\n",
+ " (7, 19): 69,\n",
+ " (19, 3): 91,\n",
+ " (18, 9): 33,\n",
+ " (8, 15): 3,\n",
+ " (9, 14): 97,\n",
+ " (8, 2): 93,\n",
+ " (10, 13): 92,\n",
+ " (9, 3): 24,\n",
+ " (11, 0): 5,\n",
+ " (9, 16): 94,\n",
+ " (14, 15): 12,\n",
+ " (12, 11): 0,\n",
+ " (15, 14): 79,\n",
+ " (14, 2): 30,\n",
+ " (13, 10): 62,\n",
+ " (2, 17): 36,\n",
+ " (0, 1): 49,\n",
+ " (3, 12): 48,\n",
+ " (1, 12): 56,\n",
+ " (4, 15): 57,\n",
+ " (3, 1): 40,\n",
+ " (2, 11): 5,\n",
+ " (5, 14): 35,\n",
+ " (3, 18): 29,\n",
+ " (6, 13): 47,\n",
+ " (7, 8): 26,\n",
+ " (6, 16): 39,\n",
+ " (19, 8): 72,\n",
+ " (18, 0): 91,\n",
+ " (17, 8): 89,\n",
+ " (16, 16): 40,\n",
+ " (18, 15): 53,\n",
+ " (8, 9): 20,\n",
+ " (9, 4): 92,\n",
+ " (7, 11): 47,\n",
+ " (10, 3): 68,\n",
+ " (12, 2): 53,\n",
+ " (11, 10): 80,\n",
+ " (14, 5): 84,\n",
+ " (13, 3): 32,\n",
+ " (12, 13): 86,\n",
+ " (1, 16): 42,\n",
+ " (3, 13): 68,\n",
+ " (15, 0): 12,\n",
+ " (13, 16): 46,\n",
+ " (1, 5): 47,\n",
+ " (0, 11): 16,\n",
+ " (3, 6): 28,\n",
+ " (2, 2): 31,\n",
+ " (1, 10): 17,\n",
+ " (4, 1): 17,\n",
+ " (6, 4): 63,\n",
+ " (5, 4): 67,\n",
+ " (16, 4): 66,\n",
+ " (6, 11): 31,\n",
+ " (5, 17): 30,\n",
+ " (19, 17): 16,\n",
+ " (17, 1): 56,\n",
+ " (7, 18): 1,\n",
+ " (19, 2): 65,\n",
+ " (18, 6): 64,\n",
+ " (9, 13): 73,\n",
+ " (8, 3): 69,\n",
+ " (10, 10): 3,\n",
+ " (9, 2): 71,\n",
+ " (16, 13): 4,\n",
+ " (11, 3): 56,\n",
+ " (14, 12): 21,\n",
+ " (12, 4): 22,\n",
+ " (15, 9): 97,\n",
+ " (14, 3): 56,\n",
+ " (13, 9): 61,\n",
+ " (0, 2): 81,\n",
+ " (3, 15): 87,\n",
+ " (1, 3): 70,\n",
+ " (4, 8): 66,\n",
+ " (3, 0): 97,\n",
+ " (2, 8): 58,\n",
+ " (5, 13): 94,\n",
+ " (6, 2): 14,\n",
+ " (16, 14): 33,\n",
+ " (6, 17): 23,\n",
+ " (19, 11): 57,\n",
+ " (18, 1): 62,\n",
+ " (17, 15): 93,\n",
+ " (16, 17): 74,\n",
+ " (18, 12): 17,\n",
+ " (8, 10): 15,\n",
+ " (9, 11): 58,\n",
+ " (10, 0): 4,\n",
+ " (8, 16): 24,\n",
+ " (12, 3): 1,\n",
+ " (11, 13): 13,\n",
+ " (14, 10): 16,\n",
+ " (13, 2): 88,\n",
+ " (12, 14): 16,\n",
+ " (15, 3): 71,\n",
+ " (13, 15): 55,\n",
+ " (1, 4): 31,\n",
+ " (0, 12): 86,\n",
+ " (3, 9): 9,\n",
+ " (2, 3): 95,\n",
+ " (1, 9): 36,\n",
+ " (4, 2): 55,\n",
+ " (2, 14): 8,\n",
+ " (6, 5): 45,\n",
+ " (5, 3): 60,\n",
+ " (16, 5): 35,\n",
+ " (6, 8): 99,\n",
+ " (5, 16): 25,\n",
+ " (19, 16): 36,\n",
+ " (17, 0): 77,\n",
+ " (7, 13): 69,\n",
+ " (19, 5): 50,\n",
+ " (18, 7): 94,\n",
+ " (7, 9): 44,\n",
+ " (18, 18): 5,\n",
+ " (9, 12): 44,\n",
+ " (8, 4): 41,\n",
+ " (10, 11): 88,\n",
+ " (9, 1): 87,\n",
+ " (17, 5): 17,\n",
+ " (11, 2): 67,\n",
+ " (10, 6): 40,\n",
+ " (16, 11): 36,\n",
+ " (14, 13): 17,\n",
+ " (12, 5): 78,\n",
+ " (0, 16): 4,\n",
+ " (15, 8): 88,\n",
+ " (14, 0): 52,\n",
+ " (13, 8): 83,\n",
+ " (12, 16): 8,\n",
+ " (0, 3): 52,\n",
+ " (15, 5): 20,\n",
+ " (3, 14): 83,\n",
+ " (1, 2): 49,\n",
+ " (4, 9): 75,\n",
+ " (3, 3): 23,\n",
+ " (2, 9): 23,\n",
+ " (5, 12): 71,\n",
+ " (4, 4): 51,\n",
+ " (6, 3): 11,\n",
+ " (8, 8): 97,\n",
+ " (7, 2): 29,\n",
+ " (7, 10): 67,\n",
+ " (19, 10): 92,\n",
+ " (17, 14): 27,\n",
+ " (16, 18): 23,\n",
+ " (18, 13): 55,\n",
+ " (17, 19): 19,\n",
+ " (8, 11): 55,\n",
+ " (9, 10): 94,\n",
+ " (10, 1): 17,\n",
+ " (8, 17): 34,\n",
+ " (11, 12): 37,\n",
+ " (15, 17): 85,\n",
+ " (14, 11): 54,\n",
+ " (13, 1): 43,\n",
+ " (12, 15): 46,\n",
+ " (11, 17): 69,\n",
+ " (15, 2): 3,\n",
+ " (13, 14): 26,\n",
+ " (0, 13): 19,\n",
+ " (3, 8): 5,\n",
+ " (2, 0): 22,\n",
+ " (1, 8): 55,\n",
+ " (4, 3): 4,\n",
+ " (2, 15): 68,\n",
+ " (5, 2): 79}"
+ ]
+ }
+ ],
+ "prompt_number": 41
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "gt_again = {(x,y): grid_nums[x + y * COLUMNS] \n",
+ " for x in range(ROWS) \n",
+ " for y in range(COLUMNS)}\n",
+ "gt_again[(3,2)]"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "metadata": {},
+ "output_type": "pyout",
+ "prompt_number": 43,
+ "text": [
+ "73"
+ ]
+ }
+ ],
+ "prompt_number": 43
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "grid_nums = [int(n) for n in GRID_STRING.split()]\n",
+ "grid_nums"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "metadata": {},
+ "output_type": "pyout",
+ "prompt_number": 28,
+ "text": [
+ "[8,\n",
+ " 2,\n",
+ " 22,\n",
+ " 97,\n",
+ " 38,\n",
+ " 15,\n",
+ " 0,\n",
+ " 40,\n",
+ " 0,\n",
+ " 75,\n",
+ " 4,\n",
+ " 5,\n",
+ " 7,\n",
+ " 78,\n",
+ " 52,\n",
+ " 12,\n",
+ " 50,\n",
+ " 77,\n",
+ " 91,\n",
+ " 8,\n",
+ " 49,\n",
+ " 49,\n",
+ " 99,\n",
+ " 40,\n",
+ " 17,\n",
+ " 81,\n",
+ " 18,\n",
+ " 57,\n",
+ " 60,\n",
+ " 87,\n",
+ " 17,\n",
+ " 40,\n",
+ " 98,\n",
+ " 43,\n",
+ " 69,\n",
+ " 48,\n",
+ " 4,\n",
+ " 56,\n",
+ " 62,\n",
+ " 0,\n",
+ " 81,\n",
+ " 49,\n",
+ " 31,\n",
+ " 73,\n",
+ " 55,\n",
+ " 79,\n",
+ " 14,\n",
+ " 29,\n",
+ " 93,\n",
+ " 71,\n",
+ " 40,\n",
+ " 67,\n",
+ " 53,\n",
+ " 88,\n",
+ " 30,\n",
+ " 3,\n",
+ " 49,\n",
+ " 13,\n",
+ " 36,\n",
+ " 65,\n",
+ " 52,\n",
+ " 70,\n",
+ " 95,\n",
+ " 23,\n",
+ " 4,\n",
+ " 60,\n",
+ " 11,\n",
+ " 42,\n",
+ " 69,\n",
+ " 24,\n",
+ " 68,\n",
+ " 56,\n",
+ " 1,\n",
+ " 32,\n",
+ " 56,\n",
+ " 71,\n",
+ " 37,\n",
+ " 2,\n",
+ " 36,\n",
+ " 91,\n",
+ " 22,\n",
+ " 31,\n",
+ " 16,\n",
+ " 71,\n",
+ " 51,\n",
+ " 67,\n",
+ " 63,\n",
+ " 89,\n",
+ " 41,\n",
+ " 92,\n",
+ " 36,\n",
+ " 54,\n",
+ " 22,\n",
+ " 40,\n",
+ " 40,\n",
+ " 28,\n",
+ " 66,\n",
+ " 33,\n",
+ " 13,\n",
+ " 80,\n",
+ " 24,\n",
+ " 47,\n",
+ " 32,\n",
+ " 60,\n",
+ " 99,\n",
+ " 3,\n",
+ " 45,\n",
+ " 2,\n",
+ " 44,\n",
+ " 75,\n",
+ " 33,\n",
+ " 53,\n",
+ " 78,\n",
+ " 36,\n",
+ " 84,\n",
+ " 20,\n",
+ " 35,\n",
+ " 17,\n",
+ " 12,\n",
+ " 50,\n",
+ " 32,\n",
+ " 98,\n",
+ " 81,\n",
+ " 28,\n",
+ " 64,\n",
+ " 23,\n",
+ " 67,\n",
+ " 10,\n",
+ " 26,\n",
+ " 38,\n",
+ " 40,\n",
+ " 67,\n",
+ " 59,\n",
+ " 54,\n",
+ " 70,\n",
+ " 66,\n",
+ " 18,\n",
+ " 38,\n",
+ " 64,\n",
+ " 70,\n",
+ " 67,\n",
+ " 26,\n",
+ " 20,\n",
+ " 68,\n",
+ " 2,\n",
+ " 62,\n",
+ " 12,\n",
+ " 20,\n",
+ " 95,\n",
+ " 63,\n",
+ " 94,\n",
+ " 39,\n",
+ " 63,\n",
+ " 8,\n",
+ " 40,\n",
+ " 91,\n",
+ " 66,\n",
" 49,\n",
" 94,\n",
" 21,\n",
]
}
],
- "prompt_number": 21
+ "prompt_number": 28
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "g1[2][4]"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "metadata": {},
+ "output_type": "pyout",
+ "prompt_number": 32,
+ "text": [
+ "55"
+ ]
+ }
+ ],
+ "prompt_number": 32
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "g1 = []\n",
+ "for rowstart in range(0, ROWS * COLUMNS, COLUMNS):\n",
+ " g1.append(grid_nums[rowstart:rowstart+COLUMNS])\n",
+ "g1"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "metadata": {},
+ "output_type": "pyout",
+ "prompt_number": 29,
+ "text": [
+ "[[8, 2, 22, 97, 38, 15, 0, 40, 0, 75, 4, 5, 7, 78, 52, 12, 50, 77, 91, 8],\n",
+ " [49,\n",
+ " 49,\n",
+ " 99,\n",
+ " 40,\n",
+ " 17,\n",
+ " 81,\n",
+ " 18,\n",
+ " 57,\n",
+ " 60,\n",
+ " 87,\n",
+ " 17,\n",
+ " 40,\n",
+ " 98,\n",
+ " 43,\n",
+ " 69,\n",
+ " 48,\n",
+ " 4,\n",
+ " 56,\n",
+ " 62,\n",
+ " 0],\n",
+ " [81,\n",
+ " 49,\n",
+ " 31,\n",
+ " 73,\n",
+ " 55,\n",
+ " 79,\n",
+ " 14,\n",
+ " 29,\n",
+ " 93,\n",
+ " 71,\n",
+ " 40,\n",
+ " 67,\n",
+ " 53,\n",
+ " 88,\n",
+ " 30,\n",
+ " 3,\n",
+ " 49,\n",
+ " 13,\n",
+ " 36,\n",
+ " 65],\n",
+ " [52, 70, 95, 23, 4, 60, 11, 42, 69, 24, 68, 56, 1, 32, 56, 71, 37, 2, 36, 91],\n",
+ " [22,\n",
+ " 31,\n",
+ " 16,\n",
+ " 71,\n",
+ " 51,\n",
+ " 67,\n",
+ " 63,\n",
+ " 89,\n",
+ " 41,\n",
+ " 92,\n",
+ " 36,\n",
+ " 54,\n",
+ " 22,\n",
+ " 40,\n",
+ " 40,\n",
+ " 28,\n",
+ " 66,\n",
+ " 33,\n",
+ " 13,\n",
+ " 80],\n",
+ " [24,\n",
+ " 47,\n",
+ " 32,\n",
+ " 60,\n",
+ " 99,\n",
+ " 3,\n",
+ " 45,\n",
+ " 2,\n",
+ " 44,\n",
+ " 75,\n",
+ " 33,\n",
+ " 53,\n",
+ " 78,\n",
+ " 36,\n",
+ " 84,\n",
+ " 20,\n",
+ " 35,\n",
+ " 17,\n",
+ " 12,\n",
+ " 50],\n",
+ " [32,\n",
+ " 98,\n",
+ " 81,\n",
+ " 28,\n",
+ " 64,\n",
+ " 23,\n",
+ " 67,\n",
+ " 10,\n",
+ " 26,\n",
+ " 38,\n",
+ " 40,\n",
+ " 67,\n",
+ " 59,\n",
+ " 54,\n",
+ " 70,\n",
+ " 66,\n",
+ " 18,\n",
+ " 38,\n",
+ " 64,\n",
+ " 70],\n",
+ " [67,\n",
+ " 26,\n",
+ " 20,\n",
+ " 68,\n",
+ " 2,\n",
+ " 62,\n",
+ " 12,\n",
+ " 20,\n",
+ " 95,\n",
+ " 63,\n",
+ " 94,\n",
+ " 39,\n",
+ " 63,\n",
+ " 8,\n",
+ " 40,\n",
+ " 91,\n",
+ " 66,\n",
+ " 49,\n",
+ " 94,\n",
+ " 21],\n",
+ " [24,\n",
+ " 55,\n",
+ " 58,\n",
+ " 5,\n",
+ " 66,\n",
+ " 73,\n",
+ " 99,\n",
+ " 26,\n",
+ " 97,\n",
+ " 17,\n",
+ " 78,\n",
+ " 78,\n",
+ " 96,\n",
+ " 83,\n",
+ " 14,\n",
+ " 88,\n",
+ " 34,\n",
+ " 89,\n",
+ " 63,\n",
+ " 72],\n",
+ " [21, 36, 23, 9, 75, 0, 76, 44, 20, 45, 35, 14, 0, 61, 33, 97, 34, 31, 33, 95],\n",
+ " [78, 17, 53, 28, 22, 75, 31, 67, 15, 94, 3, 80, 4, 62, 16, 14, 9, 53, 56, 92],\n",
+ " [16,\n",
+ " 39,\n",
+ " 5,\n",
+ " 42,\n",
+ " 96,\n",
+ " 35,\n",
+ " 31,\n",
+ " 47,\n",
+ " 55,\n",
+ " 58,\n",
+ " 88,\n",
+ " 24,\n",
+ " 0,\n",
+ " 17,\n",
+ " 54,\n",
+ " 24,\n",
+ " 36,\n",
+ " 29,\n",
+ " 85,\n",
+ " 57],\n",
+ " [86, 56, 0, 48, 35, 71, 89, 7, 5, 44, 44, 37, 44, 60, 21, 58, 51, 54, 17, 58],\n",
+ " [19,\n",
+ " 80,\n",
+ " 81,\n",
+ " 68,\n",
+ " 5,\n",
+ " 94,\n",
+ " 47,\n",
+ " 69,\n",
+ " 28,\n",
+ " 73,\n",
+ " 92,\n",
+ " 13,\n",
+ " 86,\n",
+ " 52,\n",
+ " 17,\n",
+ " 77,\n",
+ " 4,\n",
+ " 89,\n",
+ " 55,\n",
+ " 40],\n",
+ " [4, 52, 8, 83, 97, 35, 99, 16, 7, 97, 57, 32, 16, 26, 26, 79, 33, 27, 98, 66],\n",
+ " [88,\n",
+ " 36,\n",
+ " 68,\n",
+ " 87,\n",
+ " 57,\n",
+ " 62,\n",
+ " 20,\n",
+ " 72,\n",
+ " 3,\n",
+ " 46,\n",
+ " 33,\n",
+ " 67,\n",
+ " 46,\n",
+ " 55,\n",
+ " 12,\n",
+ " 32,\n",
+ " 63,\n",
+ " 93,\n",
+ " 53,\n",
+ " 69],\n",
+ " [4,\n",
+ " 42,\n",
+ " 16,\n",
+ " 73,\n",
+ " 38,\n",
+ " 25,\n",
+ " 39,\n",
+ " 11,\n",
+ " 24,\n",
+ " 94,\n",
+ " 72,\n",
+ " 18,\n",
+ " 8,\n",
+ " 46,\n",
+ " 29,\n",
+ " 32,\n",
+ " 40,\n",
+ " 62,\n",
+ " 76,\n",
+ " 36],\n",
+ " [20,\n",
+ " 69,\n",
+ " 36,\n",
+ " 41,\n",
+ " 72,\n",
+ " 30,\n",
+ " 23,\n",
+ " 88,\n",
+ " 34,\n",
+ " 62,\n",
+ " 99,\n",
+ " 69,\n",
+ " 82,\n",
+ " 67,\n",
+ " 59,\n",
+ " 85,\n",
+ " 74,\n",
+ " 4,\n",
+ " 36,\n",
+ " 16],\n",
+ " [20,\n",
+ " 73,\n",
+ " 35,\n",
+ " 29,\n",
+ " 78,\n",
+ " 31,\n",
+ " 90,\n",
+ " 1,\n",
+ " 74,\n",
+ " 31,\n",
+ " 49,\n",
+ " 71,\n",
+ " 48,\n",
+ " 86,\n",
+ " 81,\n",
+ " 16,\n",
+ " 23,\n",
+ " 57,\n",
+ " 5,\n",
+ " 54],\n",
+ " [1,\n",
+ " 70,\n",
+ " 54,\n",
+ " 71,\n",
+ " 83,\n",
+ " 51,\n",
+ " 54,\n",
+ " 69,\n",
+ " 16,\n",
+ " 92,\n",
+ " 33,\n",
+ " 48,\n",
+ " 61,\n",
+ " 43,\n",
+ " 52,\n",
+ " 1,\n",
+ " 89,\n",
+ " 19,\n",
+ " 67,\n",
+ " 48]]"
+ ]
+ }
+ ],
+ "prompt_number": 29
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "g3 = [grid_nums[rowstart:rowstart+COLUMNS] \n",
+ " for rowstart in range(0, ROWS * COLUMNS, COLUMNS)]\n",
+ "g3"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "metadata": {},
+ "output_type": "pyout",
+ "prompt_number": 45,
+ "text": [
+ "[[8, 2, 22, 97, 38, 15, 0, 40, 0, 75, 4, 5, 7, 78, 52, 12, 50, 77, 91, 8],\n",
+ " [49,\n",
+ " 49,\n",
+ " 99,\n",
+ " 40,\n",
+ " 17,\n",
+ " 81,\n",
+ " 18,\n",
+ " 57,\n",
+ " 60,\n",
+ " 87,\n",
+ " 17,\n",
+ " 40,\n",
+ " 98,\n",
+ " 43,\n",
+ " 69,\n",
+ " 48,\n",
+ " 4,\n",
+ " 56,\n",
+ " 62,\n",
+ " 0],\n",
+ " [81,\n",
+ " 49,\n",
+ " 31,\n",
+ " 73,\n",
+ " 55,\n",
+ " 79,\n",
+ " 14,\n",
+ " 29,\n",
+ " 93,\n",
+ " 71,\n",
+ " 40,\n",
+ " 67,\n",
+ " 53,\n",
+ " 88,\n",
+ " 30,\n",
+ " 3,\n",
+ " 49,\n",
+ " 13,\n",
+ " 36,\n",
+ " 65],\n",
+ " [52, 70, 95, 23, 4, 60, 11, 42, 69, 24, 68, 56, 1, 32, 56, 71, 37, 2, 36, 91],\n",
+ " [22,\n",
+ " 31,\n",
+ " 16,\n",
+ " 71,\n",
+ " 51,\n",
+ " 67,\n",
+ " 63,\n",
+ " 89,\n",
+ " 41,\n",
+ " 92,\n",
+ " 36,\n",
+ " 54,\n",
+ " 22,\n",
+ " 40,\n",
+ " 40,\n",
+ " 28,\n",
+ " 66,\n",
+ " 33,\n",
+ " 13,\n",
+ " 80],\n",
+ " [24,\n",
+ " 47,\n",
+ " 32,\n",
+ " 60,\n",
+ " 99,\n",
+ " 3,\n",
+ " 45,\n",
+ " 2,\n",
+ " 44,\n",
+ " 75,\n",
+ " 33,\n",
+ " 53,\n",
+ " 78,\n",
+ " 36,\n",
+ " 84,\n",
+ " 20,\n",
+ " 35,\n",
+ " 17,\n",
+ " 12,\n",
+ " 50],\n",
+ " [32,\n",
+ " 98,\n",
+ " 81,\n",
+ " 28,\n",
+ " 64,\n",
+ " 23,\n",
+ " 67,\n",
+ " 10,\n",
+ " 26,\n",
+ " 38,\n",
+ " 40,\n",
+ " 67,\n",
+ " 59,\n",
+ " 54,\n",
+ " 70,\n",
+ " 66,\n",
+ " 18,\n",
+ " 38,\n",
+ " 64,\n",
+ " 70],\n",
+ " [67,\n",
+ " 26,\n",
+ " 20,\n",
+ " 68,\n",
+ " 2,\n",
+ " 62,\n",
+ " 12,\n",
+ " 20,\n",
+ " 95,\n",
+ " 63,\n",
+ " 94,\n",
+ " 39,\n",
+ " 63,\n",
+ " 8,\n",
+ " 40,\n",
+ " 91,\n",
+ " 66,\n",
+ " 49,\n",
+ " 94,\n",
+ " 21],\n",
+ " [24,\n",
+ " 55,\n",
+ " 58,\n",
+ " 5,\n",
+ " 66,\n",
+ " 73,\n",
+ " 99,\n",
+ " 26,\n",
+ " 97,\n",
+ " 17,\n",
+ " 78,\n",
+ " 78,\n",
+ " 96,\n",
+ " 83,\n",
+ " 14,\n",
+ " 88,\n",
+ " 34,\n",
+ " 89,\n",
+ " 63,\n",
+ " 72],\n",
+ " [21, 36, 23, 9, 75, 0, 76, 44, 20, 45, 35, 14, 0, 61, 33, 97, 34, 31, 33, 95],\n",
+ " [78, 17, 53, 28, 22, 75, 31, 67, 15, 94, 3, 80, 4, 62, 16, 14, 9, 53, 56, 92],\n",
+ " [16,\n",
+ " 39,\n",
+ " 5,\n",
+ " 42,\n",
+ " 96,\n",
+ " 35,\n",
+ " 31,\n",
+ " 47,\n",
+ " 55,\n",
+ " 58,\n",
+ " 88,\n",
+ " 24,\n",
+ " 0,\n",
+ " 17,\n",
+ " 54,\n",
+ " 24,\n",
+ " 36,\n",
+ " 29,\n",
+ " 85,\n",
+ " 57],\n",
+ " [86, 56, 0, 48, 35, 71, 89, 7, 5, 44, 44, 37, 44, 60, 21, 58, 51, 54, 17, 58],\n",
+ " [19,\n",
+ " 80,\n",
+ " 81,\n",
+ " 68,\n",
+ " 5,\n",
+ " 94,\n",
+ " 47,\n",
+ " 69,\n",
+ " 28,\n",
+ " 73,\n",
+ " 92,\n",
+ " 13,\n",
+ " 86,\n",
+ " 52,\n",
+ " 17,\n",
+ " 77,\n",
+ " 4,\n",
+ " 89,\n",
+ " 55,\n",
+ " 40],\n",
+ " [4, 52, 8, 83, 97, 35, 99, 16, 7, 97, 57, 32, 16, 26, 26, 79, 33, 27, 98, 66],\n",
+ " [88,\n",
+ " 36,\n",
+ " 68,\n",
+ " 87,\n",
+ " 57,\n",
+ " 62,\n",
+ " 20,\n",
+ " 72,\n",
+ " 3,\n",
+ " 46,\n",
+ " 33,\n",
+ " 67,\n",
+ " 46,\n",
+ " 55,\n",
+ " 12,\n",
+ " 32,\n",
+ " 63,\n",
+ " 93,\n",
+ " 53,\n",
+ " 69],\n",
+ " [4,\n",
+ " 42,\n",
+ " 16,\n",
+ " 73,\n",
+ " 38,\n",
+ " 25,\n",
+ " 39,\n",
+ " 11,\n",
+ " 24,\n",
+ " 94,\n",
+ " 72,\n",
+ " 18,\n",
+ " 8,\n",
+ " 46,\n",
+ " 29,\n",
+ " 32,\n",
+ " 40,\n",
+ " 62,\n",
+ " 76,\n",
+ " 36],\n",
+ " [20,\n",
+ " 69,\n",
+ " 36,\n",
+ " 41,\n",
+ " 72,\n",
+ " 30,\n",
+ " 23,\n",
+ " 88,\n",
+ " 34,\n",
+ " 62,\n",
+ " 99,\n",
+ " 69,\n",
+ " 82,\n",
+ " 67,\n",
+ " 59,\n",
+ " 85,\n",
+ " 74,\n",
+ " 4,\n",
+ " 36,\n",
+ " 16],\n",
+ " [20,\n",
+ " 73,\n",
+ " 35,\n",
+ " 29,\n",
+ " 78,\n",
+ " 31,\n",
+ " 90,\n",
+ " 1,\n",
+ " 74,\n",
+ " 31,\n",
+ " 49,\n",
+ " 71,\n",
+ " 48,\n",
+ " 86,\n",
+ " 81,\n",
+ " 16,\n",
+ " 23,\n",
+ " 57,\n",
+ " 5,\n",
+ " 54],\n",
+ " [1,\n",
+ " 70,\n",
+ " 54,\n",
+ " 71,\n",
+ " 83,\n",
+ " 51,\n",
+ " 54,\n",
+ " 69,\n",
+ " 16,\n",
+ " 92,\n",
+ " 33,\n",
+ " 48,\n",
+ " 61,\n",
+ " 43,\n",
+ " 52,\n",
+ " 1,\n",
+ " 89,\n",
+ " 19,\n",
+ " 67,\n",
+ " 48]]"
+ ]
+ }
+ ],
+ "prompt_number": 45
},
{
"cell_type": "code",
"collapsed": false,
"input": [
- "g1 = []\n",
+ "g1=[]\n",
"for rowstart in range(0, ROWS * COLUMNS, COLUMNS):\n",
" g1.append(grid_nums[rowstart:rowstart+COLUMNS])\n",
"g1"
"language": "python",
"metadata": {},
"outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "[8, 2, 22, 97, 38, 15, 0, 40, 0, 75, 4, 5, 7, 78, 52, 12, 50, 77, 91, 8]\n",
+ "[49, 49, 99, 40, 17, 81, 18, 57, 60, 87, 17, 40, 98, 43, 69, 48, 4, 56, 62, 0]\n",
+ "[81, 49, 31, 73, 55, 79, 14, 29, 93, 71, 40, 67, 53, 88, 30, 3, 49, 13, 36, 65]\n",
+ "[52, 70, 95, 23, 4, 60, 11, 42, 69, 24, 68, 56, 1, 32, 56, 71, 37, 2, 36, 91]\n",
+ "[22, 31, 16, 71, 51, 67, 63, 89, 41, 92, 36, 54, 22, 40, 40, 28, 66, 33, 13, 80]\n",
+ "[24, 47, 32, 60, 99, 3, 45, 2, 44, 75, 33, 53, 78, 36, 84, 20, 35, 17, 12, 50]\n",
+ "[32, 98, 81, 28, 64, 23, 67, 10, 26, 38, 40, 67, 59, 54, 70, 66, 18, 38, 64, 70]\n",
+ "[67, 26, 20, 68, 2, 62, 12, 20, 95, 63, 94, 39, 63, 8, 40, 91, 66, 49, 94, 21]\n",
+ "[24, 55, 58, 5, 66, 73, 99, 26, 97, 17, 78, 78, 96, 83, 14, 88, 34, 89, 63, 72]\n",
+ "[21, 36, 23, 9, 75, 0, 76, 44, 20, 45, 35, 14, 0, 61, 33, 97, 34, 31, 33, 95]\n",
+ "[78, 17, 53, 28, 22, 75, 31, 67, 15, 94, 3, 80, 4, 62, 16, 14, 9, 53, 56, 92]\n",
+ "[16, 39, 5, 42, 96, 35, 31, 47, 55, 58, 88, 24, 0, 17, 54, 24, 36, 29, 85, 57]\n",
+ "[86, 56, 0, 48, 35, 71, 89, 7, 5, 44, 44, 37, 44, 60, 21, 58, 51, 54, 17, 58]\n",
+ "[19, 80, 81, 68, 5, 94, 47, 69, 28, 73, 92, 13, 86, 52, 17, 77, 4, 89, 55, 40]\n",
+ "[4, 52, 8, 83, 97, 35, 99, 16, 7, 97, 57, 32, 16, 26, 26, 79, 33, 27, 98, 66]\n",
+ "[88, 36, 68, 87, 57, 62, 20, 72, 3, 46, 33, 67, 46, 55, 12, 32, 63, 93, 53, 69]\n",
+ "[4, 42, 16, 73, 38, 25, 39, 11, 24, 94, 72, 18, 8, 46, 29, 32, 40, 62, 76, 36]\n",
+ "[20, 69, 36, 41, 72, 30, 23, 88, 34, 62, 99, 69, 82, 67, 59, 85, 74, 4, 36, 16]\n",
+ "[20, 73, 35, 29, 78, 31, 90, 1, 74, 31, 49, 71, 48, 86, 81, 16, 23, 57, 5, 54]\n",
+ "[1, 70, 54, 71, 83, 51, 54, 69, 16, 92, 33, 48, 61, 43, 52, 1, 89, 19, 67, 48]\n"
+ ]
+ },
{
"metadata": {},
"output_type": "pyout",
- "prompt_number": 24,
+ "prompt_number": 39,
"text": [
"[[8, 2, 22, 97, 38, 15, 0, 40, 0, 75, 4, 5, 7, 78, 52, 12, 50, 77, 91, 8],\n",
" [49,\n",
]
}
],
- "prompt_number": 24
+ "prompt_number": 39
},
{
"cell_type": "code",
],
"prompt_number": 76
},
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "import collections\n",
+ "import string\n",
+ "collections.Counter(l for l in open('sherlock-holmes.txt').read()\n",
+ " if l in string.ascii_letters)"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "metadata": {},
+ "output_type": "pyout",
+ "prompt_number": 51,
+ "text": [
+ "Counter({'e': 52876, 't': 37842, 'a': 34376, 'o': 33200, 'n': 28378, 'h': 27803, 's': 26432, 'i': 26366, 'r': 24304, 'd': 18349, 'l': 16854, 'u': 13070, 'm': 11055, 'w': 10508, 'c': 10172, 'y': 8976, 'f': 8785, 'g': 7733, 'p': 6652, 'b': 5883, 'v': 4367, 'I': 3774, 'k': 3465, 'H': 1244, 'T': 1139, 'S': 762, 'A': 761, 'W': 758, 'M': 732, 'x': 541, 'B': 479, 'Y': 455, 'q': 406, 'j': 338, 'C': 327, 'O': 312, 'N': 304, 'L': 291, 'E': 235, 'D': 214, 'R': 204, 'F': 190, 'P': 183, 'G': 154, 'z': 147, 'J': 114, 'V': 85, 'K': 78, 'U': 46, 'Q': 20, 'X': 8, 'Z': 2})"
+ ]
+ }
+ ],
+ "prompt_number": 51
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "import collections\n",
+ "import string\n",
+ "c = collections.Counter(l.lower() for l in open('sherlock-holmes.txt').read()\n",
+ " if l in string.ascii_letters)\n",
+ "[(l, c[l]) for l in sorted(c)]"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "metadata": {},
+ "output_type": "pyout",
+ "prompt_number": 50,
+ "text": [
+ "[('a', 35137),\n",
+ " ('b', 6362),\n",
+ " ('c', 10499),\n",
+ " ('d', 18563),\n",
+ " ('e', 53111),\n",
+ " ('f', 8975),\n",
+ " ('g', 7887),\n",
+ " ('h', 29047),\n",
+ " ('i', 30140),\n",
+ " ('j', 452),\n",
+ " ('k', 3543),\n",
+ " ('l', 17145),\n",
+ " ('m', 11787),\n",
+ " ('n', 28682),\n",
+ " ('o', 33512),\n",
+ " ('p', 6835),\n",
+ " ('q', 426),\n",
+ " ('r', 24508),\n",
+ " ('s', 27194),\n",
+ " ('t', 38981),\n",
+ " ('u', 13116),\n",
+ " ('v', 4452),\n",
+ " ('w', 11266),\n",
+ " ('x', 549),\n",
+ " ('y', 9431),\n",
+ " ('z', 149)]"
+ ]
+ }
+ ],
+ "prompt_number": 50
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "import random\n",
+ "import collections\n",
+ "import string"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [],
+ "prompt_number": 52
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "def only_lower_case(str):\n",
+ " ???\n",
+ " return ???"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": []
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "words = [line.strip() \n",
+ " for line in open('/usr/share/dict/british-english').readlines()\n",
+ " if only_lower_case(line)]\n",
+ "words[:20]"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "metadata": {},
+ "output_type": "pyout",
+ "prompt_number": 57,
+ "text": [
+ "['A',\n",
+ " \"A's\",\n",
+ " \"AA's\",\n",
+ " \"AB's\",\n",
+ " \"ABM's\",\n",
+ " \"AC's\",\n",
+ " \"ACTH's\",\n",
+ " \"AI's\",\n",
+ " \"AIDS's\",\n",
+ " \"AM's\",\n",
+ " 'AOL',\n",
+ " \"AOL's\",\n",
+ " \"ASCII's\",\n",
+ " \"ASL's\",\n",
+ " \"ATM's\",\n",
+ " \"ATP's\",\n",
+ " \"AWOL's\",\n",
+ " \"AZ's\",\n",
+ " \"AZT's\",\n",
+ " 'Aachen']"
+ ]
+ }
+ ],
+ "prompt_number": 57
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "string.ascii_letters"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "metadata": {},
+ "output_type": "pyout",
+ "prompt_number": 58,
+ "text": [
+ "'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ'"
+ ]
+ }
+ ],
+ "prompt_number": 58
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "string.ascii_lowercase"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "metadata": {},
+ "output_type": "pyout",
+ "prompt_number": 60,
+ "text": [
+ "'abcdefghijklmnopqrstuvwxyz'"
+ ]
+ }
+ ],
+ "prompt_number": 60
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "string.ascii_uppercase"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "metadata": {},
+ "output_type": "pyout",
+ "prompt_number": 61,
+ "text": [
+ "'ABCDEFGHIJKLMNOPQRSTUVWXYZ'"
+ ]
+ }
+ ],
+ "prompt_number": 61
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "string.punctuation"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "metadata": {},
+ "output_type": "pyout",
+ "prompt_number": 62,
+ "text": [
+ "'!\"#$%&\\'()*+,-./:;<=>?@[\\\\]^_`{|}~'"
+ ]
+ }
+ ],
+ "prompt_number": 62
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "'b' in string.ascii_lowercase"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "metadata": {},
+ "output_type": "pyout",
+ "prompt_number": 63,
+ "text": [
+ "True"
+ ]
+ }
+ ],
+ "prompt_number": 63
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "'B' in string.ascii_lowercase"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "metadata": {},
+ "output_type": "pyout",
+ "prompt_number": 64,
+ "text": [
+ "False"
+ ]
+ }
+ ],
+ "prompt_number": 64
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "[l for l in 'hello']"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "metadata": {},
+ "output_type": "pyout",
+ "prompt_number": 65,
+ "text": [
+ "['h', 'e', 'l', 'l', 'o']"
+ ]
+ }
+ ],
+ "prompt_number": 65
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "for l in 'hello':\n",
+ " print(l)"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "h\n",
+ "e\n",
+ "l\n",
+ "l\n",
+ "o\n"
+ ]
+ }
+ ],
+ "prompt_number": 66
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "'b' not in string.ascii_lowercase"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "metadata": {},
+ "output_type": "pyout",
+ "prompt_number": 67,
+ "text": [
+ "False"
+ ]
+ }
+ ],
+ "prompt_number": 67
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "'B' not in string.ascii_lowercase"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "metadata": {},
+ "output_type": "pyout",
+ "prompt_number": 68,
+ "text": [
+ "True"
+ ]
+ }
+ ],
+ "prompt_number": 68
+ },
{
"cell_type": "code",
"collapsed": false,