color: #ff6666;
text-shadow: 0 0 20px #333;
padding: 2px 5px;
+ }
+ .indexlink {
+ position: absolute;
+ bottom: 1em;
+ left: 1em;
}
.float-right {
float: right;
---
+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?
---
+# 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.