First bit of the A-level miscellany master
authorNeil Smith <neil.git@njae.me.uk>
Thu, 5 Mar 2015 23:58:19 +0000 (23:58 +0000)
committerNeil Smith <neil.git@njae.me.uk>
Thu, 5 Mar 2015 23:58:19 +0000 (23:58 +0000)
Hash_table_5_0_1_1_1_1_1_LL.svg [new file with mode: 0644]
Karnaugh_map2.png [new file with mode: 0644]
SIGNED.md
Untitled1.ipynb [new file with mode: 0644]
a-level-miscellany.html [new file with mode: 0644]
index.html

diff --git a/Hash_table_5_0_1_1_1_1_1_LL.svg b/Hash_table_5_0_1_1_1_1_1_LL.svg
new file mode 100644 (file)
index 0000000..73a2b83
--- /dev/null
@@ -0,0 +1,254 @@
+<?xml version="1.0" encoding="UTF-8" standalone="no"?>
+<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
+<!-- Created on 2009-04-10 by Jorge Stolfi with the script make-hash-table-figure -->
+
+<svg
+  xmlns="http://www.w3.org/2000/svg"
+  xmlns:xlink="http://www.w3.org/1999/xlink"
+  width="450.0"
+  height="310.0"
+  id="fig"
+  stroke-linejoin="round"
+  stroke-opacity="1"
+  stroke-linecap="round"
+  fill-opacity="1"
+  fill-rule="evenodd"
+  font-family="Bitstream Courier"
+  font-style="normal"
+  font-weight="normal"
+  pagecolor="#ffff00"
+  pageopacity="0.0">
+
+
+  <g
+    font-size="12px"
+    transform="scale(1.0) translate(10,60)"
+  >
+
+  <defs>
+    <!-- Start marker for non-null pointers: -->
+    <marker id="linkdot_N" viewBox="0 0 8 8" refX="4" refY="4" markerWidth="8" markerHeight="8" orient="auto">
+      <circle cx="4" cy="4" r="3" stroke="#000000" fill="#000000" />
+    </marker>
+    <!-- Start marker for null pointers: -->
+    <marker id="linkdot_U" viewBox="0 0 8 8" refX="4" refY="4" markerWidth="8" markerHeight="8" orient="auto">
+      <line x1="1" y1="1" x2="7" y2="7" stroke="#000000" />
+      <line x1="1" y1="7" x2="7" y2="1" stroke="#000000" />
+    </marker>
+
+    <!-- Tip for arrows: -->
+    <marker id="arrowtip_N" viewBox="0 0 14 8" refX="13" refY="4" markerWidth="14" markerHeight="8" orient="auto">
+      <polygon points="1,4  1,1  13,4  1,7" stroke="#000000" fill="#000000" />
+    </marker>
+    <!-- Tip for highlighted arrows: -->
+    <marker id="arrowtip_C" viewBox="0 0 14 8" refX="13" refY="4" markerWidth="14" markerHeight="8" orient="auto">
+      <polygon points="1,4  1,1  13,4  1,7" stroke="#cc0000" fill="#cc0000" />
+    </marker>
+
+    <!-- Key box in input column, normal: -->
+    <rect id="key_box_N"   y="0" x="0" width="90" height="20" fill="#00ffff" stroke="none" />
+    <!-- Key box in input column, highlighted : -->
+    <rect id="key_box_C"   y="0" x="0" width="90" height="20" fill="#00ffff" stroke="none" />
+    <!-- Key box in bucket or overflow columns, normal: -->
+    <rect id="key_box_E"   y="0" x="0" width="90" height="20" fill="#9cff9c" stroke="#000000" />
+    <!-- Key box in bucket or overflow columns, vacant: -->
+    <rect id="key_box_U"   y="0" x="0" width="90" height="20" fill="#ddeedd" stroke="#000000" />
+
+    <!-- Value box in bucket or overflow columns, occupied: -->
+    <rect id="val_box_E"   y="0" x="0" width="80" height="20" fill="#9cff9c" stroke="#000000" />
+    <!-- Value box in bucket or overflow columns, vacant: -->
+    <rect id="val_box_U"   y="0" x="0" width="80" height="20" fill="#ddeedd" stroke="#000000" />
+
+    <!-- Pointer box in bucket or overflow columns, used and non-null: -->
+    <rect id="ptr_box_E"   y="0" x="0" width="20" height="20" fill="#9cff9c" stroke="#000000" />
+    <!-- Pointer box in bucket or overflow columns, null/vacant: -->
+    <rect id="ptr_box_U"   y="0" x="0" width="20" height="20" fill="#ddeedd" stroke="#000000" />
+
+    <!-- Background for hash value, unused: -->
+    <rect id="hsh_box_U" x="3" y="1" width="34" height="18" fill="#ddeedd" stroke="none" />
+    <!-- Background for hash value, used: -->
+    <rect id="hsh_box_N" x="3" y="1" width="34" height="18" fill="#a8a8ff" stroke="none" />
+    <!-- Background for hash value, highlighted: -->
+    <rect id="hsh_box_C" x="3" y="1" width="34" height="18" fill="#ee4444" stroke="none" />
+
+    <!-- Vertical dots: -->
+    <g id="vdots">
+      <rect x="0" y="06" width="2" height="2" />
+      <rect x="0" y="12" width="2" height="2" />
+    </g>
+ </defs>
+
+    <!-- Keys and hash function -->
+    <g transform="translate(0,000)" text-anchor="middle" stroke="none">
+
+      <text x="45" y="-10" font-size="15px" font-weight="bold" fill="#000000" stroke="none"> keys
+ </text>
+
+      <g transform="translate(0,30)">
+        <use xlink:href="#key_box_C" />
+        <text x="45" y="14" stroke="none">John Smith</text>
+        <line x1="95" y1="10" x2="100" y2="10" stroke="#dd0000" />
+        <line x1="100" y1="10" x2="130" y2="80" stroke="#dd0000" />
+        <line x1="130" y1="80" x2="150" y2="80" stroke="#dd0000" marker-end="url(#arrowtip_C)" />
+      </g>
+      <g transform="translate(0,70)">
+        <use xlink:href="#key_box_N" />
+        <text x="45" y="14" stroke="none">Lisa Smith</text>
+        <line x1="95" y1="10" x2="100" y2="10" stroke="#000000" />
+        <line x1="100" y1="10" x2="130" y2="-40" stroke="#000000" />
+        <line x1="130" y1="-40" x2="150" y2="-40" stroke="#000000" marker-end="url(#arrowtip_N)" />
+      </g>
+      <g transform="translate(0,110)">
+        <use xlink:href="#key_box_N" />
+        <text x="45" y="14" stroke="none">Sam Doe</text>
+        <line x1="95" y1="10" x2="100" y2="10" stroke="#000000" />
+        <line x1="100" y1="10" x2="130" y2="100" stroke="#000000" />
+        <line x1="130" y1="100" x2="150" y2="100" stroke="#000000" marker-end="url(#arrowtip_N)" />
+      </g>
+      <g transform="translate(0,150)">
+        <use xlink:href="#key_box_C" />
+        <text x="45" y="14" stroke="none">Sandra Dee</text>
+        <line x1="95" y1="10" x2="100" y2="10" stroke="#dd0000" />
+        <line x1="100" y1="10" x2="130" y2="-40" stroke="#dd0000" />
+        <line x1="130" y1="-40" x2="150" y2="-40" stroke="#dd0000" marker-end="url(#arrowtip_C)" />
+      </g>
+      <g transform="translate(0,190)">
+        <use xlink:href="#key_box_N" />
+        <text x="45" y="14" stroke="none">Ted Baker</text>
+        <line x1="95" y1="10" x2="100" y2="10" stroke="#000000" />
+        <line x1="100" y1="10" x2="130" y2="-60" stroke="#000000" />
+        <line x1="130" y1="-60" x2="150" y2="-60" stroke="#000000" marker-end="url(#arrowtip_N)" />
+      </g>
+
+    </g>
+
+    <!-- Hash values and bucket array -->
+    <g transform="translate(150,000)" text-anchor="middle" stroke="none">
+
+      <text x="50" y="-10" font-size="15px" font-weight="bold" fill="#000000" stroke="none">
+ buckets
+ </text>
+
+      <g transform="translate(000,0)">
+        <use x="0" xlink:href="#hsh_box_U" />
+        <text x="20" y="14">000</text>
+        <use x="40" xlink:href="#ptr_box_U" />
+        <line x1="50" y1="10" x2="50.000999999999998" y2="10" stroke="#000000" marker-start="url(#linkdot_U)" />
+      </g>
+      <g transform="translate(000,20)">
+        <use x="0" xlink:href="#hsh_box_N" />
+        <text x="20" y="14">001</text>
+        <use x="40" xlink:href="#ptr_box_E" />
+        <line x1="50" y1="10" x2="90" y2="0" stroke="#000000" marker-start="url(#linkdot_N)" marker-end="url(#arrowtip_N)" />
+      </g>
+      <g transform="translate(000,40)">
+        <use x="0" xlink:href="#hsh_box_U" />
+        <text x="20" y="14">002</text>
+        <use x="40" xlink:href="#ptr_box_U" />
+        <line x1="50" y1="10" x2="50.000999999999998" y2="10" stroke="#000000" marker-start="url(#linkdot_U)" />
+      </g>
+      <g transform="translate(000,60)">
+        <text x="20" y="14" font-weight="bold">:</text>
+        <text x="50" y="14" font-weight="bold">:</text>
+      </g>
+      <g transform="translate(000,80)">
+        <use x="0" xlink:href="#hsh_box_U" />
+        <text x="20" y="14">151</text>
+        <use x="40" xlink:href="#ptr_box_U" />
+        <line x1="50" y1="10" x2="50.000999999999998" y2="10" stroke="#000000" marker-start="url(#linkdot_U)" />
+      </g>
+      <g transform="translate(000,100)">
+        <use x="0" xlink:href="#hsh_box_C" />
+        <text x="20" y="14">152</text>
+        <use x="40" xlink:href="#ptr_box_E" />
+        <line x1="50" y1="10" x2="90" y2="-30" stroke="#000000" marker-start="url(#linkdot_N)" marker-end="url(#arrowtip_N)" />
+      </g>
+      <g transform="translate(000,120)">
+        <use x="0" xlink:href="#hsh_box_N" />
+        <text x="20" y="14">153</text>
+        <use x="40" xlink:href="#ptr_box_E" />
+        <line x1="50" y1="10" x2="90" y2="50" stroke="#000000" marker-start="url(#linkdot_N)" marker-end="url(#arrowtip_N)" />
+      </g>
+      <g transform="translate(000,140)">
+        <use x="0" xlink:href="#hsh_box_U" />
+        <text x="20" y="14">154</text>
+        <use x="40" xlink:href="#ptr_box_U" />
+        <line x1="50" y1="10" x2="50.000999999999998" y2="10" stroke="#000000" marker-start="url(#linkdot_U)" />
+      </g>
+      <g transform="translate(000,160)">
+        <text x="20" y="14" font-weight="bold">:</text>
+        <text x="50" y="14" font-weight="bold">:</text>
+      </g>
+      <g transform="translate(000,180)">
+        <use x="0" xlink:href="#hsh_box_U" />
+        <text x="20" y="14">253</text>
+        <use x="40" xlink:href="#ptr_box_U" />
+        <line x1="50" y1="10" x2="50.000999999999998" y2="10" stroke="#000000" marker-start="url(#linkdot_U)" />
+      </g>
+      <g transform="translate(000,200)">
+        <use x="0" xlink:href="#hsh_box_N" />
+        <text x="20" y="14">254</text>
+        <use x="40" xlink:href="#ptr_box_E" />
+        <line x1="50" y1="10" x2="90" y2="20" stroke="#000000" marker-start="url(#linkdot_N)" marker-end="url(#arrowtip_N)" />
+      </g>
+      <g transform="translate(000,220)">
+        <use x="0" xlink:href="#hsh_box_U" />
+        <text x="20" y="14">255</text>
+        <use x="40" xlink:href="#ptr_box_U" />
+        <line x1="50" y1="10" x2="50.000999999999998" y2="10" stroke="#000000" marker-start="url(#linkdot_U)" />
+      </g>
+
+    </g>
+
+    <!-- Hash values and bucket array -->
+    <g transform="translate(240,000)" text-anchor="middle" stroke="none">
+
+      <text x="95" y="-10" font-size="15px" font-weight="bold" fill="#000000" stroke="none">
+ entries
+ </text>
+
+      <g transform="translate(000,10)">
+        <use x="0" xlink:href="#ptr_box_E" />
+        <line x1="10" y1="10" x2="10" y2="10.000999999999999" stroke="#000000" marker-start="url(#linkdot_U)" />
+        <use x="20" xlink:href="#key_box_E" />
+        <text x="65" y="14">Lisa Smith</text>
+        <use x="110" xlink:href="#val_box_E" />
+        <text x="150" y="14">521-8976</text>
+      </g>
+      <g transform="translate(000,60)">
+        <use x="0" xlink:href="#ptr_box_E" />
+        <line x1="10" y1="10" x2="10" y2="50" stroke="#000000" marker-start="url(#linkdot_N)" marker-end="url(#arrowtip_N)" />
+        <use x="20" xlink:href="#key_box_E" />
+        <text x="65" y="14">John Smith</text>
+        <use x="110" xlink:href="#val_box_E" />
+        <text x="150" y="14">521-1234</text>
+      </g>
+      <g transform="translate(000,110)">
+        <use x="0" xlink:href="#ptr_box_E" />
+        <line x1="10" y1="10" x2="10" y2="10.000999999999999" stroke="#000000" marker-start="url(#linkdot_U)" />
+        <use x="20" xlink:href="#key_box_E" />
+        <text x="65" y="14">Sandra Dee</text>
+        <use x="110" xlink:href="#val_box_E" />
+        <text x="150" y="14">521-9655</text>
+      </g>
+      <g transform="translate(000,160)">
+        <use x="0" xlink:href="#ptr_box_E" />
+        <line x1="10" y1="10" x2="10" y2="10.000999999999999" stroke="#000000" marker-start="url(#linkdot_U)" />
+        <use x="20" xlink:href="#key_box_E" />
+        <text x="65" y="14">Ted Baker</text>
+        <use x="110" xlink:href="#val_box_E" />
+        <text x="150" y="14">418-4165</text>
+      </g>
+      <g transform="translate(000,210)">
+        <use x="0" xlink:href="#ptr_box_E" />
+        <line x1="10" y1="10" x2="10" y2="10.000999999999999" stroke="#000000" marker-start="url(#linkdot_U)" />
+        <use x="20" xlink:href="#key_box_E" />
+        <text x="65" y="14">Sam Doe</text>
+        <use x="110" xlink:href="#val_box_E" />
+        <text x="150" y="14">521-5030</text>
+      </g>
+
+    </g>
+
+  </g>
+</svg>
diff --git a/Karnaugh_map2.png b/Karnaugh_map2.png
new file mode 100644 (file)
index 0000000..a4eed10
Binary files /dev/null and b/Karnaugh_map2.png differ
index 91947e68b6a944c978188559c8ed99304a6327aa..7964d97b8af97a09b91c87cd83e3025eeb1ada5f 100644 (file)
--- a/SIGNED.md
+++ b/SIGNED.md
@@ -3,19 +3,19 @@
 -----BEGIN PGP SIGNATURE-----
 Version: GnuPG v2
 
 -----BEGIN PGP SIGNATURE-----
 Version: GnuPG v2
 
-iQIcBAABAgAGBQJU53KIAAoJEJPB2e07PgbqI38P/j/eQEa78/O/0rw7Gvnnglut
-pHkghfKnyX0NSTif8OpK7MtxikwC8h8BMu7+KOX+BZu31RAZxeXVdxHkyKXT7/jD
-YLXPeK/803362bsJiL9yebVf5C1it8opIzCGe/nx6O+bLHqO8eEuaB9xmE5CnS+T
-etEijh889LP3dwKPjYia+kJci55mHLoVgWQzXbQQnvc8Pi3TNRbHOehdSRgGOa5k
-g5HAJdggPGgnTrzItsA86yZzAdjgSBbJvs/aGn4Qjx5w+wiiN0BANI3/H3cgP7Hc
-Yeby1VfFo3Kqpp48EggTw54+Tgvco17QB3PQj4Nux/FbdKeSS+eT/2m/4uOVblXT
-w8tcmZS9DHctD/g3e+9C0eAcVZgSygzdFhK7zJ1o3x0z0Ic9/qcHxaWvijcExjeB
-E0gr2matR9zZshRJKLlKs975xoQL9OlcpZHcvVijAkp9aCr8/zgGWlrFmNHnMqKx
-bg2LxV3SgKpoTvpqAWEugUD4OgSZ2iuqCVhqMnCt5hesqmHJSJ7wH5t1XyEml8mx
-z1VDeMWtVAf/xjU9tN/++JWVFH9YxvL/2FFuREWYch35dc9LuUUrwkUk+dR+sdW9
-D8y51adNR1cfzVefzyInBku3tu+lE3JRGKizT9rdWl8V+kq9Ma9BiGrn1W8LYHI3
-+M56lSm5HEJK+lQ0W7TP
-=ywOf
+iQIcBAABAgAGBQJU+O2fAAoJEJPB2e07PgbqUS8P/RXy5zccLlaXhVVSjC2bwBk9
+87Ibf1DoiJVIfZ3iPKLiqv66L3KyDjBTlpNvH8XvvRkQ1i4M5tdWEWeqWkKJXAAd
+yo+k5dAX7if4jvzpt9d88CituRBhn9AtXnlhwx0vVfYU2f7amhlWN5TEhPUbzrKG
+V5JWXQv1So4ZIU5bHSj2Qd3exQAVxWpm/OY239E7WlahgkbUzqzzd9KdLvyeSjE9
+JSQ+8yotXBu12wMNhrwmd/spa1UTFhD602h6Vcur7QmFAftm/eFID+IY+wFfsjou
+WXSM7SgL3PXkKCzSCHYhO41y3XFalBMfFqeri0iV7J1y8rLPfchmm10NZZOZTz3Q
+M+lPFa9BTRLZ5HlwC9w0hmnFaqBHQetEnscu3V+7qst0QPUvGM9QWvfn87HRwB1i
+8fahdrVBrwrJceEOfcnLov4zMeoR5x61J1VNPBuWtVZ9BVczjlkJBs+NflbM0uFu
+lE2jwcqgrMBpPATNs7L4GfNbWJdRhd3d3meZhSxnxe0O7fubX8mm3gXGB96+r/58
+ppfb5axeeU/DC+B0og/xUmqSAjwP9YYUqjSv7zu6YMVj3UDLJZVdb/RoRkA4AlCI
+BJUEtMKvCe7wRoMbS91oA8UvOFqxkC05qBpPnwBmOJs5hbGbeg8fu7j8WK1K3DBs
+cPHT6YsBiIb8dR1F7RFS
+=yzXB
 -----END PGP SIGNATURE-----
 
 ```
 -----END PGP SIGNATURE-----
 
 ```
@@ -30,9 +30,12 @@ D8y51adNR1cfzVefzyInBku3tu+lE3JRGKizT9rdWl8V+kq9Ma9BiGrn1W8LYHI3
 size    exec  file                                 contents                                                                                                                         
               ./                                                                                                                                                                    
 384             .gitignore                         a93de2ae5c2a47a38599751d1f914566569dfa09dd1778e207117db6c71421dd                                                                 
 size    exec  file                                 contents                                                                                                                         
               ./                                                                                                                                                                    
 384             .gitignore                         a93de2ae5c2a47a38599751d1f914566569dfa09dd1778e207117db6c71421dd                                                                 
+11547           Hash_table_5_0_1_1_1_1_1_LL.svg    e95ff61c4b3a5e202fdea793673e5288321aade8eaac1e9bc61229ee0a27c7ba                                                                 
+2643            Karnaugh_map2.png                  fffe1982ec61fea8cc6488c7bf7206572297962419f3ee71d95867e27f7c9d87|30ce6e3887da5efb4068383508a86bc6e38153c53c307a23c29632795b166bd3
 339             README.md                          b6a32e10a4a36e2de32385dedef3e88bad767c41a92caeb93086d5065ac0a188                                                                 
 78868           Untitled0.ipynb                    8ac2a76fb3b6f29f2b3a35c4db46c35ec81d053c9a86bec8a1dee48905d5953a                                                                 
 1363            Untitled1.ipynb                    ef878c0d63f138a496713f862ef177f4346942944b690ad48589e7adb929b62d                                                                 
 339             README.md                          b6a32e10a4a36e2de32385dedef3e88bad767c41a92caeb93086d5065ac0a188                                                                 
 78868           Untitled0.ipynb                    8ac2a76fb3b6f29f2b3a35c4db46c35ec81d053c9a86bec8a1dee48905d5953a                                                                 
 1363            Untitled1.ipynb                    ef878c0d63f138a496713f862ef177f4346942944b690ad48589e7adb929b62d                                                                 
+7656            a-level-miscellany.html            d0df27fdaeeebfb886193b8b2f68204e625093d363021e8dee5adfd8b1cfbd1d                                                                 
 81789           alan-turing.jpg                    52fc427b7eee09b10682cf36594ff9038f497c856c284d912f44c7603561969b|300c9f022062d629ec4f4bcb7192d732ca850d0ab92f9f39b2b90981979abdf7
 13180           algorithms.html                    5d983371c7ba55108c68d19a8dfe419dfa387587b764415bce09c59e55d1c5da                                                                 
 20722           big-o-chart-2-smaller.png          e57e10b28aa20f09b308fee493a996cea11a374160edd36a82170730130b7446|d0f348376c076c50c429756da7ee020e545aa5ff781fe4b983662cf23f503d0b
 81789           alan-turing.jpg                    52fc427b7eee09b10682cf36594ff9038f497c856c284d912f44c7603561969b|300c9f022062d629ec4f4bcb7192d732ca850d0ab92f9f39b2b90981979abdf7
 13180           algorithms.html                    5d983371c7ba55108c68d19a8dfe419dfa387587b764415bce09c59e55d1c5da                                                                 
 20722           big-o-chart-2-smaller.png          e57e10b28aa20f09b308fee493a996cea11a374160edd36a82170730130b7446|d0f348376c076c50c429756da7ee020e545aa5ff781fe4b983662cf23f503d0b
@@ -63,7 +66,7 @@ size    exec  file                                 contents
 5366            hangman.html                       64a75e50559c236118e2cc91651f5ac7091d14f3d27b7038a3d4770beb3dee08                                                                 
 4167            hangman2.html                      84014a67033d320605b3ae2eacc6a2f622560a2694487624c39d9fd66a9278f4                                                                 
 41276           human-computer-worksheet.png       354fa591f28e7b979f8efa9ed6423ce76e019601628945ac61b173bf6107ce60|11073eea5462dd9fbd056cc6694dbab62408e251c64001dc7090060d7fbf96ff
 5366            hangman.html                       64a75e50559c236118e2cc91651f5ac7091d14f3d27b7038a3d4770beb3dee08                                                                 
 4167            hangman2.html                      84014a67033d320605b3ae2eacc6a2f622560a2694487624c39d9fd66a9278f4                                                                 
 41276           human-computer-worksheet.png       354fa591f28e7b979f8efa9ed6423ce76e019601628945ac61b173bf6107ce60|11073eea5462dd9fbd056cc6694dbab62408e251c64001dc7090060d7fbf96ff
-2191            index.html                         4b8e1de469018e557ce42955c3ede679f08d8a5421a9b1c5cb91ae03ed681a75                                                                 
+2265            index.html                         a104a11703f9ca8b58711265a6d60c6f105c9061e7d8aeab898d1f344f0368be                                                                 
 650             make-change.dot                    cc56b42a08ee78b0ec2afa8c96ce4574ae546f959e535e68605beb66394247c1                                                                 
 54549           make-change.dot.png                7c46cdaac91b084a95903de65685906d2c61cd1c55d740936ec6f1bb9050ee22|bd52720ce8c4b7350caed16cc72954757550f4e62e8a030f151922ac9a11dffe
 2216            oulogo_hor.png                     93dae19a7dde063927ca9a3ec7d468cc20f0bc4da9091fdf4819273ab4cf524a|f73072930ecf211ce23d4559b9fbdd11c1be4a0451fa6a8f74ad803d4f5f71ee
 650             make-change.dot                    cc56b42a08ee78b0ec2afa8c96ce4574ae546f959e535e68605beb66394247c1                                                                 
 54549           make-change.dot.png                7c46cdaac91b084a95903de65685906d2c61cd1c55d740936ec6f1bb9050ee22|bd52720ce8c4b7350caed16cc72954757550f4e62e8a030f151922ac9a11dffe
 2216            oulogo_hor.png                     93dae19a7dde063927ca9a3ec7d468cc20f0bc4da9091fdf4819273ab4cf524a|f73072930ecf211ce23d4559b9fbdd11c1be4a0451fa6a8f74ad803d4f5f71ee
diff --git a/Untitled1.ipynb b/Untitled1.ipynb
new file mode 100644 (file)
index 0000000..bf17f6f
--- /dev/null
@@ -0,0 +1,75 @@
+{
+ "metadata": {
+  "name": "",
+  "signature": "sha256:383dbd07426142dba085750cea664fb5a2eb5d274834904c9266a800ddf86c5c"
+ },
+ "nbformat": 3,
+ "nbformat_minor": 0,
+ "worksheets": [
+  {
+   "cells": [
+    {
+     "cell_type": "code",
+     "collapsed": false,
+     "input": [
+      "def anagram1(word1, word2):\n",
+      "    return sorted(word1) == sorted(word2)"
+     ],
+     "language": "python",
+     "metadata": {},
+     "outputs": [],
+     "prompt_number": 2
+    },
+    {
+     "cell_type": "code",
+     "collapsed": false,
+     "input": [
+      "anagram1('happy', 'sad')"
+     ],
+     "language": "python",
+     "metadata": {},
+     "outputs": [
+      {
+       "metadata": {},
+       "output_type": "pyout",
+       "prompt_number": 3,
+       "text": [
+        "False"
+       ]
+      }
+     ],
+     "prompt_number": 3
+    },
+    {
+     "cell_type": "code",
+     "collapsed": false,
+     "input": [
+      "anagram1('happy', 'hpayp')"
+     ],
+     "language": "python",
+     "metadata": {},
+     "outputs": [
+      {
+       "metadata": {},
+       "output_type": "pyout",
+       "prompt_number": 4,
+       "text": [
+        "True"
+       ]
+      }
+     ],
+     "prompt_number": 4
+    },
+    {
+     "cell_type": "code",
+     "collapsed": false,
+     "input": [],
+     "language": "python",
+     "metadata": {},
+     "outputs": []
+    }
+   ],
+   "metadata": {}
+  }
+ ]
+}
\ No newline at end of file
diff --git a/a-level-miscellany.html b/a-level-miscellany.html
new file mode 100644 (file)
index 0000000..832a4f0
--- /dev/null
@@ -0,0 +1,231 @@
+<!DOCTYPE html>
+<html>
+  <head>
+    <title>A Level Miscellany</title>
+    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
+    <style type="text/css">
+      /* Slideshow styles */
+      body {
+        font-size: 20px;
+      }
+      h1, h2, h3 {
+        font-weight: 400;
+        margin-bottom: 0;
+      }
+      h1 { font-size: 3em; }
+      h2 { font-size: 2em; }
+      h3 { font-size: 1.6em; }
+      a, a > code {
+        text-decoration: none;
+      }
+      code {
+        -moz-border-radius: 5px;
+        -web-border-radius: 5px;
+        background: #e7e8e2;
+        border-radius: 5px;
+        font-size: 16px;
+      }
+      .plaintext {
+        background: #272822;
+        color: #80ff80;
+        text-shadow: 0 0 20px #333;
+        padding: 2px 5px;
+      }
+      .ciphertext {
+        background: #272822;
+        color: #ff6666;
+        text-shadow: 0 0 20px #333;
+        padding: 2px 5px;
+      }
+      .indexlink {
+        position: absolute;
+        bottom: 1em;
+        left: 1em;
+      }
+       .float-right {
+        float: right;
+      }
+    </style>
+  </head>
+  <body>
+    <textarea id="source">
+
+# A-level Miscellany ![Open University logo](oulogo_hor.png)
+
+* Hashing
+* Boolean algebra
+* Karnaugh maps
+* Python file handling
+
+---
+
+layout: true
+
+.indexlink[![Open University logo](oulogo_hor.png) [Index](index.html)]
+
+---
+
+# Hashing
+
+Convert any of a large range of value to a small range of values
+
+Two purposes:
+
+1. Putting many things in few buckets
+2. Cryptographic signing
+
+---
+
+# Hashing many things into a few buckets
+Useful for dividing items into files, or balancing items across any data structure. 
+
+Some examples (from [Geoff Kuenning's old course notes](http://www.cs.hmc.edu/~geoff/classes/hmc.cs070.200101/homework10/hashfuncs.html))
+.float-right[![Chaining hash table collisions: from https://commons.wikimedia.org/wiki/File:Hash_table_5_0_1_1_1_1_1_LL.svg#mediaviewer/File:Hash_table_5_0_1_1_1_1_1_LL.svg](Hash_table_5_0_1_1_1_1_1_LL.svg)]
+
+* **Division method** (Cormen) Choose a prime that isn't close to a power of 2. h(k) = k mod m. Works badly for many types of patterns in the input data.
+
+* **Knuth Variant on Division** h(k) = k(k+3) mod m. Supposedly works much better than the raw division method.
+
+* **Multiplication Method** (Cormen). Choose m to be a power of 2. Let A be some random-looking real number. Knuth suggests M = 0.5*(sqrt(5) - 1). Then do the following:
+    1. s = k × A
+    2. x = fractional part of s
+    3. h(k) = floor(m × x)
+
+Problem of hash collisions, where multiple items provide the same hash value. In a data structure, do something like chain multiple values together.
+
+---
+
+# Cryptographic hash functions
+
+Maps a large file into a smaller space of values, e.g. SHA-256 maps any file to a 256-bit digest
+
+Cryptographic hashes have additional features:
+
+* Easy to compute
+* One way: can't derive a source from a hash
+* Sensitive: modifying a source changes the hash
+* Few collisions: different souces have different hashes
+
+MD5, SHA-1 in common use, but broken. SHA-2 developed by NSA, but seems secure...
+
+Useful for validating messages, downloaded files, etc.
+
+* Alice posts message and hash
+* Bob downloads message and hash
+* Bob computes hash for message and compares to what Alice posted
+* If they're equal, Bob's happy that the download was successful
+* If Eve changed the message in transit, the hashes won't be the same
+
+---
+
+# Signing messages: authentication
+
+Assume a public key encryption scheme.
+
+* Alice finds a message's hash, encrypts it with her private key
+* Alice sends the message plus encrypted hash to Bob
+* Bob decrypts the hash with Alice's public key
+* Bob hashes message and compares it what Alice sent
+* If they're the same, Bob knows
+    1. The message wasn't changed in transit
+    2. Alice must have sent the message, as only she had the private key
+
+See also TU100 Block 5 Part 3 on cryptography and security.
+
+---
+
+# Bitcoin
+Hashes used as proof of work for 'mining' bitcoins.
+
+* Block is transaction history + nonce word
+* Challenge is to find a nonce word that gives a hash in the correct range
+* No shortcut: must try many, many nonces and see what works
+
+---
+
+ # Boolean algegra identities
+
+|Rule | Left | Right | 
+|------|----:|:----|
+|`\(\text{Associativity of } \vee                             \)`|`\( x \vee (y \vee z)     \)`|`\( = (x \vee y) \vee z \)`|
+|`\(\text{Associativity of } \wedge                           \)`|`\( x \wedge (y \wedge z) \)`|`\( = (x \wedge y) \wedge z \)`|
+|`\(\text{Commutativity of } \vee                             \)`|`\( x \vee y              \)`|`\( = y \vee x \)`|
+|`\(\text{Commutativity of } \wedge                           \)`|`\( x \wedge y            \)`|`\( = y \wedge x \)`|
+|`\(\text{Distributivity of } \wedge \text{ over } \vee \quad \)`|`\( x \wedge (y \vee z)   \)`|`\( = (x \wedge y) \vee (x \wedge z) \)`|
+|`\(\text{Identity for } \vee                                 \)`|`\( x \vee 0              \)`|`\( = x \)`|
+|`\(\text{Identity for } \wedge                               \)`|`\( x \wedge 1            \)`|`\( = x \)`|
+|`\(\text{Annihilator for } \wedge                            \)`|`\( x \wedge 0            \)`|`\( = 0 \)`|
+|`\(\text{Double negation }                                   \)`|`\( \neg \neg x           \)`|`\( = x \)`|
+|`\(\text{De Morgan's Law }                                   \)`|`\( \neg ( x \wedge y )   \)`|`\( = \neg x \vee \neg y \)`|
+|`\(\text{De Morgan's Law }                                   \)`|`\( \neg ( x \vee y )     \)`|`\( = \neg x \wedge \neg y \)`|
+
+You can prove all these by truth tables.
+
+---
+
+# Boolean Notation
+
+`\( \wedge = \& = × = \cdot  = \text{and}\)` ; `\( \vee = | = + = \text{or}\)` ; `\( \neg x = \: \sim x = x' = \overline x = \text{not}\)`
+
+## implies
+
+`implies` is a connective: `\(a \text{ implies } b = a \rightarrow b = a \supset b = \neg a \vee b \)`
+
+`\( A \)` | `\( B \)` | `\( \neg A \)` | `\( \neg A \vee B \)` | `\( A \rightarrow B \)`
+:--------:|:---------:|:--------------:|:---------------------:|:-----------------------:
+    F     |     F     |       T        |           T           |          T
+    F     |     T     |       T        |           T           |          T
+    T     |     F     |       F        |           F           |          F
+    T     |     T     |       T        |           T           |          T
+
+If A is true, B must be true. If A is false, B can be anything.
+
+Use other notation for derivations and proofs: see your friendly mathematicians.
+
+---
+
+#Karnaugh maps
+
+.float-right[![Karnaugh maps](Karnaugh_map2.png)]
+
+A way of visually simplifying Boolean expressions. 
+
+Draw the biggest loops you can, don't worry if the overlap.
+
+---
+
+# File handling in Python
+
+* Reading, writing appending
+* `read()` and `readlines()`
+* Text and binary
+* Text encodings
+
+
+
+
+    </textarea>
+    <script src="http://gnab.github.io/remark/downloads/remark-0.6.0.min.js" type="text/javascript">
+    </script>
+
+    <script type="text/javascript"
+      src="http://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS-MML_HTMLorMML&delayStartupUntil=configured"></script>
+
+    <script type="text/javascript">
+      var slideshow = remark.create({ ratio: "16:9" });
+
+      // Setup MathJax
+      MathJax.Hub.Config({
+        tex2jax: {
+        skipTags: ['script', 'noscript', 'style', 'textarea', 'pre']
+        }
+      });
+      MathJax.Hub.Queue(function() {
+        $(MathJax.Hub.getAllJax()).map(function(index, elem) {
+            return(elem.SourceElement());
+        }).parent().addClass('has-jax');
+      });
+      MathJax.Hub.Configured();
+    </script>
+  </body>
+</html>
index 14184be61e6f8e2fb40f74ff0d16dec145b6a499..5abad1734f9287dbfb06005b9b56987bdffddd07 100644 (file)
@@ -60,6 +60,9 @@
 * [Hangman part 2](hangman2.html)
 * [Algorithms](algorithms.html)
 
 * [Hangman part 2](hangman2.html)
 * [Algorithms](algorithms.html)
 
+# CAS A-level miscellany
+
+* [A level miscellany](a-level-miscellany.html)
 
     </textarea>
     <script src="http://gnab.github.io/remark/downloads/remark-0.6.0.min.js" type="text/javascript">
 
     </textarea>
     <script src="http://gnab.github.io/remark/downloads/remark-0.6.0.min.js" type="text/javascript">