<!DOCTYPE html>
<html>
<head>
- <title>Breaking keyword ciphers</title>
+ <title>Further work</title>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
<style type="text/css">
/* Slideshow styles */
<textarea id="source">
# Taking this further
-
-### Countdown
+
+
+<table>
+<tr valign="top">
+<td>
+### Countdown
+
* Conundrum
* Letters
* Picking letters to maximise score
* Numbers
* Read the "Functional Pearl"
-
+</td>
+<td>
### Hangman
* Letter probabilities based on each word occurring once in the dictionary
* Set of candidate words filtered by length, letters guessed
-
+</td>
+</tr>
+<tr>
+<td>
### Text generation
* Read some text, find the n-grams, generate more text from that.
-
+</td>
+<td>
### Spelling correction
* Suggest the most likely correct word, given the probability of these errors.
+</td>
+</tr>
+</table>
</textarea>
<script src="http://gnab.github.io/remark/downloads/remark-0.6.0.min.js" type="text/javascript">
<!DOCTYPE html>
<html>
<head>
- <title>Keyword ciphers</title>
+ <title>Index of cipher training</title>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
<style type="text/css">
/* Slideshow styles */
# Cipher programming training
* [Aims](aims.html)
-* Caesar ciphers: [Making](caesar-encipher.html) and [Breaking](caesar-break.html)
-* Affine ciphers: [Making](affine-encipher.html) and [Breaking](affine-break.html)
-* [Word segmentation](word-segmentation.html)
-* Keyword ciphers: [Making](keyword-encipher.html) and [Breaking](keyword-break.html)
-* Transposition ciphers: [Making](transposition-encipher.html) and [Breaking](transposition-break.html)
-* [Alternative plausability scoring](alternative-plaintext-scoring.html)
+* Caesar ciphers: [Making](caesar-encipher.html) and [Breaking](caesar-break.html) *(Changing representations, language models, text encodings)*
+* Affine ciphers: [Making](affine-encipher.html) and [Breaking](affine-break.html) *(Time/space trade-offs, off-by-one issues)*
+* [Word segmentation](word-segmentation.html) *(Memoisation and complexity)*
+* Keyword ciphers: [Making](keyword-encipher.html) and [Breaking](keyword-break.html) *(Being Pythonic and parallelism)*
+* Transposition ciphers: [Making](transposition-encipher.html) and [Breaking](transposition-break.html) *(Equivalence classes)*
+* Pocket enigma: [Making](pocket-enigma-encipher.html) and [Breaking](pocket-enigma-break.html) *(Object orientation)*
+* [Alternative plaintext scoring](alternative-plaintext-scoring.html) *(Empirical computing through simulation)*
* [Further work](further-work.html)
</textarea>
<!DOCTYPE html>
<html>
<head>
- <title>Keyword ciphers</title>
+ <title>Transposition ciphers</title>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
<style type="text/css">
/* Slideshow styles */
* Unwind the strip
* "Unreadable" unless reader has pole of same diameter
- attack the fort at dawn
+```
+attack the fort at dawn
- a t t a c
- k t h e f
- o r t a t
- d a w n
+a t t a c
+k t h e f
+o r t a t
+d a w n
- akod ttra aean cft
+akod ttra aean cft
+```
---
* Reorder columns based on keyword
* Read the grid (perhaps different direction)
+(Keyword = secret → cerst)
+```
+attack the fort at dawn
+
+s e c r t c e r s t
+--------- ---------
+a t t a c t t a a c
+k t h e f h t e k f
+o r t a t t r a o t
+d a w n w a n d
+
+ttaac htekf traot wand
+thtw tra aean akod cft
+```
+
Scytale is just a special case of column transposition.
---
# Grids and data structures
-How to represent a grid?
+What operations do we need to do on a grid?
-What operations do we need to do on it?
+How to represent a grid?
---
# Grids and data structures
-How to represent a grid?
-
-* List of strings
-* Each row is a string
-* Rows in order in the list
-
-What operations do we need to do on it?
+What operations do we need to do on a grid?
* Fill, by rows or columns
* Empty, by rows or columns
* Calculate the size of the grid
* Pad message to fit a rectangle of the required size
+How to represent a grid?
+
+* List of strings
+* Each row is a string
+* Rows in order in the list
+
---
# Finding sizes
Know number of columns
-Number of rows = ceiling(message length / columns)
+Number of rows = `\(\left \lceil \frac{\mathrm{message\ length}}{\mathrm{columns}} \right \rceil\)`
-Paddding is (rows * columns) - message length
+Paddding is (rows ⨉ columns) - message length
* What to use as default padding?
* Keyword parameter!
The transposition `(3, 2, 6, 5, 1, 4, 0)` says that what was in position 3 moves to position 0, what was in position 2 moves to position 1, what was in position 6 moves to position 2, ...
-`enumerate(_iterable_)` yields an iterator that walks over the iterator, including the element indexes.
+`enumerate(_iterable_)` yields an iterator that walks over the iterable, including the element indexes.
```python
>>> [i for i in enumerate('treason')]