Made a few tweaks
[cipher-training.git] / slides / keyword-break.html
index 4a2772c03ddfad8a2ece4bfee7b8f5b086c4be47..ddf82c1cf338e3ec71c9cf923a7c4242cf8d4dc7 100644 (file)
         color: #ff6666;
         text-shadow: 0 0 20px #333;
         padding: 2px 5px;
+      }
+      .indexlink {
+        position: absolute;
+        bottom: 1em;
+        left: 1em;
       }
        .float-right {
         float: right;
@@ -53,6 +58,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)]
+
+---
+
 # Duplicate and extend your `affine_break()` function
 
 * How to cycle through all the keys? What _are_ all the keys?
@@ -86,6 +97,32 @@ But before we get there, a couple of diversions...
 
 ---
 
+# DRYing code
+
+Three cipher breaking tasks so far.
+
+All working on the same principle:
+
+```
+find a way to enumerate all the possible keys
+initialise 'best so far'
+for each key:
+    decipher message with this key
+    score it
+    if it's better than the best so far:
+        update best so far
+```
+
+Repetition of code is a bad smell.
+
+Separate out
+
+* enumerate the keys
+* score a key
+* find the key with the best score
+
+---
+
 # map()
 
 A common task is to apply a function to each item in a sequence, returning a sequence of the results.