Tweaked slide layout
[cipher-training.git] / slides / keyword-encipher.html
index 7258e9c88e6ae818f0f076ec7b2675d8a7a25125..be90c688f040732636fb65fec4f152e52093d4f1 100644 (file)
@@ -1,7 +1,7 @@
 <!DOCTYPE html>
 <html>
   <head>
-    <title>Affine ciphers</title>
+    <title>Keyword ciphers</title>
     <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
     <style type="text/css">
       /* Slideshow styles */
         color: #ff6666;
         text-shadow: 0 0 20px #333;
         padding: 2px 5px;
+      }
+      .indexlink {
+        position: absolute;
+        bottom: 1em;
+        left: 1em;
       }
        .float-right {
         float: right;
@@ -55,6 +60,12 @@ k | e | y | w | o | r | d | a | b | c | f | g | h | i | j | l | m | n | p | q |
 
 ---
 
+layout: true
+
+.indexlink[[Index](index.html)]
+
+---
+
 # The cipher
 
 * Still character-by-character substitution, still monosubstitution.
@@ -103,6 +114,7 @@ Both enciphering and deciphering need the same keyword-based alphabet, so pull t
 # Keyword arguments
 
 Used to:
+
 1. give a default value for a parameter
 2. allow parameters to be named (not just positional)
 
@@ -110,8 +122,18 @@ Give our `keyword_encipher` and `keyword_decipher` procedures a keyword paramete
 
 Pass this parameter to the `keyword_alphabet` procedure.
 
-## Note: `Enum` introduced in Python 3.4. This is a better solution. 
+## wrap_alphabet has no inherent meaning
+Use Python 3.4's `Enum`
+```python
+from enum import Enum
+
+class KeywordWrapAlphabet(Enum):
+    from_a = 1
+    from_last = 2
+    from_largest = 3
+```
 
+(Use integers in earlier Pythons)
 ---
 
 # Deduplicating a sequence
@@ -141,15 +163,15 @@ Write out the rest of the alphabet...
 
 * Santitise the keyword before we use it
 
+---
+# Making the keyword alphabet
+
 ## Cases
 1. As we're deduplicating anyway, just add the entire alphabet to the end of the keyword, then deduplicate. 
 `deduplicate(keyword + string.ascii_lowercase)`
 
 2. and 3. How to find the appropriate letter of the keyword.
 
-Indexing pulls out letters. `'keyword'[0]` = 'k' ; `'keyword'[3]` = 'w' ; `'keyword'[-1]` = 'd'
-Slices pulls out substrings. `'keyword'[1:4]` = 'eyw' ; `'keyword'[:3]` = 'key' ; `'keyword'[5:]` = 'rd'
-
 `deduplicate(keyword + string_ascii_lowercase[from:] + string.ascii_lowercase)`
 
 Question: why not take a slice of the second alphabet copy?