X-Git-Url: https://git.njae.me.uk/?a=blobdiff_plain;ds=sidebyside;f=03-door-codes%2Fdoor-codes-solution.ipynb;h=8e67f00ca1da95cb16cd7812e9d3a0996dd70b82;hb=a3695711a670f04d92097fc0d664eba25685ebdf;hp=749530321d8b52411da4585896e024b58fcddb13;hpb=9996e1a0efa164d12509aa96a39fcb3d3463d39e;p=ou-summer-of-code-2017.git
diff --git a/03-door-codes/door-codes-solution.ipynb b/03-door-codes/door-codes-solution.ipynb
index 7495303..8e67f00 100644
--- a/03-door-codes/door-codes-solution.ipynb
+++ b/03-door-codes/door-codes-solution.ipynb
@@ -71,7 +71,7 @@
},
{
"cell_type": "code",
- "execution_count": 23,
+ "execution_count": 4,
"metadata": {},
"outputs": [
{
@@ -80,7 +80,7 @@
"('a', 'z', 'z', 'a')"
]
},
- "execution_count": 23,
+ "execution_count": 4,
"metadata": {},
"output_type": "execute_result"
}
@@ -91,7 +91,7 @@
},
{
"cell_type": "code",
- "execution_count": 21,
+ "execution_count": 5,
"metadata": {
"collapsed": true
},
@@ -103,10 +103,8 @@
},
{
"cell_type": "code",
- "execution_count": 26,
- "metadata": {
- "collapsed": true
- },
+ "execution_count": 7,
+ "metadata": {},
"outputs": [],
"source": [
"def whash1(word, show_steps=False):\n",
@@ -124,12 +122,7 @@
" print('| `{}` | {} | `{}` | {} | {} | {} | `{}` |'.format(\n",
" ''.join(h_before), \n",
" (o(h_before[0]), o(h_before[1])),\n",
- " l, | old code | code as
numbers | passphrase
letter | number of
letter | new first
part of code |new second
part of code | new code |\n",
- "|:---|:---|:---|:---|:---|:---|:---|\n",
- "| `th` | (20, 8) | `e` | 5 | 28 | 13 | `bm` |\n",
- "| `bm` | (2, 13) | `c` | 3 | 15 | 16 | `op` |\n",
- "| `op` | (15, 16) | `a` | 1 | 31 | 17 | `eq` |\n",
- "| `eq` | (5, 17) | `t` | 20 | 22 | 37 | `vk` |\n",
+ " l, \n",
" o(l), \n",
" o(h_before[0]) + o(h_before[1]), \n",
" o(h_before[1]) + o(l), \n",
@@ -139,7 +132,7 @@
},
{
"cell_type": "code",
- "execution_count": 27,
+ "execution_count": 8,
"metadata": {},
"outputs": [
{
@@ -160,7 +153,7 @@
"'vk'"
]
},
- "execution_count": 27,
+ "execution_count": 8,
"metadata": {},
"output_type": "execute_result"
}
@@ -171,7 +164,7 @@
},
{
"cell_type": "code",
- "execution_count": 7,
+ "execution_count": 9,
"metadata": {
"collapsed": true
},
@@ -183,7 +176,7 @@
},
{
"cell_type": "code",
- "execution_count": 8,
+ "execution_count": 10,
"metadata": {},
"outputs": [
{
@@ -192,7 +185,7 @@
"'mc'"
]
},
- "execution_count": 8,
+ "execution_count": 10,
"metadata": {},
"output_type": "execute_result"
}
@@ -218,7 +211,7 @@
"1. \"Multiply\" the second letter of the code by `alpha` then add the first letter of the code, replacing the first code letter\n",
"2. \"Multiply\" the current letter of the pass phrase by `beta` and add the second letter of the code, replacing the second letter of the code\n",
"\n",
- "\"Multiplying\" letters is done by converting the letters to their position in the alphabet (starting at one) and multiplying. For instance, to multiply `u` by 11, convert `u` to `21`, multiply by 11 (`21` Ã `11` = `231`), then convert back to a letter (`231` is larger than 26, so it becomes `22`, which is `w`).\n",
+ "\"Multiplying\" letters is done by converting the letters to their position in the alphabet (starting at one) and multiplying. For instance, to multiply `u` by 11, convert `u` to `21`, multiply by 11 (`21` Ã `11` = `231`), then convert back to a letter (`231` is larger than 26, so it becomes `23`, which is `w`).\n",
"\n",
"Again, anything that isn't a lower-case letter is ignored.\n",
"\n",
@@ -252,27 +245,27 @@
},
{
"cell_type": "code",
- "execution_count": 9,
+ "execution_count": 11,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
- "(21, 231, 22, 'w')"
+ "(21, 231, 23, 'w')"
]
},
- "execution_count": 9,
+ "execution_count": 11,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
- "o('u'), o('u') * 11, (o('u') * 11 - 1) % 26, c(o('u') * 11)"
+ "o('u'), o('u') * 11, (o('u') * 11 - 1) % 26 + 1, c(o('u') * 11)"
]
},
{
"cell_type": "code",
- "execution_count": 16,
+ "execution_count": 12,
"metadata": {},
"outputs": [
{
@@ -281,7 +274,7 @@
"(18, 9, 45, 63, 'k')"
]
},
- "execution_count": 16,
+ "execution_count": 12,
"metadata": {},
"output_type": "execute_result"
}
@@ -292,7 +285,7 @@
},
{
"cell_type": "code",
- "execution_count": 17,
+ "execution_count": 13,
"metadata": {},
"outputs": [
{
@@ -301,7 +294,7 @@
"(9, 20, 220, 229, 'u')"
]
},
- "execution_count": 17,
+ "execution_count": 13,
"metadata": {},
"output_type": "execute_result"
}
@@ -312,7 +305,7 @@
},
{
"cell_type": "code",
- "execution_count": 24,
+ "execution_count": 14,
"metadata": {
"collapsed": true
},
@@ -346,7 +339,7 @@
},
{
"cell_type": "code",
- "execution_count": 25,
+ "execution_count": 15,
"metadata": {},
"outputs": [
{
@@ -369,7 +362,7 @@
"'vl'"
]
},
- "execution_count": 25,
+ "execution_count": 15,
"metadata": {},
"output_type": "execute_result"
}
@@ -380,7 +373,7 @@
},
{
"cell_type": "code",
- "execution_count": 20,
+ "execution_count": 16,
"metadata": {},
"outputs": [
{
@@ -389,7 +382,7 @@
"'qb'"
]
},
- "execution_count": 20,
+ "execution_count": 16,
"metadata": {},
"output_type": "execute_result"
}