You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: anagram/discussion.md
+3-3Lines changed: 3 additions & 3 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -129,7 +129,7 @@ True
129
129
130
130
## Selecting words to compare
131
131
132
-
My first implementation of this program was quite naive and yet worked fine for find all other single words that were anagrams. Everything came crashing down when I attempted to find combinations. I suddenly realized the number of 2-word combinations I needed to check (that 55 *billion* I mentioned before). As it happened, I then rewatched "The Imitation Game" about Alan Turing and the creation of his machine ("Christopher") to crack the Enigma code which has a possible 150 million million possible states. He was unable to build a machine that could churn through that many possibilities in the 18 hours or so per day they had to find the right combination, so they had to find a way to cut down the number of combinations they attempted. Similarly, I realized I only needed to look at combinations of words whose lengths sum to the length of the given word; hency my decision to store `words` using the word length as the key and then as a `set` of words that length.
132
+
My first implementation of this program was quite naive and yet worked fine for find all other single words that were anagrams. Everything came crashing down when I attempted to find combinations. I suddenly realized the number of 2-word combinations I needed to check (that 55 *billion* I mentioned before). As it happened, I then rewatched "The Imitation Game" about Alan Turing and the creation of his machine ("Christopher") to crack the Enigma code which has a possible 150 million million possible states. He was unable to build a machine that could churn through that many possibilities in the 18 hours or so per day they had to find the right combination, so they had to find a way to cut down the number of combinations they attempted. Similarly, I realized I only needed to look at combinations of words whose lengths sum to the length of the given word; hence my decision to store `words` using the word length as the key and then as a `set` of words that length.
133
133
134
134
Next I needed to find all combinations of numbers that add up to that number. Let's consider we are using "listen" as the `text`:
135
135
@@ -216,7 +216,7 @@ Let's take the first combo:
216
216
````
217
217
>>> keys = key_combos[0]
218
218
>>> keys
219
-
(1, 3)
219
+
(3, 3)
220
220
````
221
221
222
222
And pretend we have a very small `words` list:
@@ -270,4 +270,4 @@ tin les
270
270
271
271
Some are repeated which is why I chose to create my `anagrams` holder as a `set` to make them unique.
272
272
273
-
In the end, I look to see how many `anagrams` I found using `len(anagrams)`. If there are some, I report how many and what they are in `sorted` order; otherwise I let the user know that none were found.
273
+
In the end, I look to see how many `anagrams` I found using `len(anagrams)`. If there are some, I report how many and what they are in `sorted` order; otherwise I let the user know that none were found.
Copy file name to clipboardExpand all lines: book.md
+13-12Lines changed: 13 additions & 12 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -4277,9 +4277,9 @@ In creating all the possible plates from your regular expression, you are making
4277
4277
4278
4278
\newpage
4279
4279
4280
-
# Chapter 26: Markov Chains for Words
4280
+
# Chapter 26: Gibberish Generator
4281
4281
4282
-
Write a Python program called `markov.py` that uses the Markov chain algorithm to generate new words from a set of training files. The program should take one or more positional arguments which are files that you read, word-by-word, and note the options of letters after a given `-k|--kmer_size` (default `2`) grouping of letters. E.g., in the word "alabama" with `k=1`, the frequency table will look like:
4282
+
Write a Python program called `gibberish.py` that uses the Markov chain algorithm to generate new words from a set of training files. The program should take one or more positional arguments which are files that you read, word-by-word, and note the options of letters after a given `-k|--kmer_size` (default `2`) grouping of letters. E.g., in the word "alabama" with `k=1`, the frequency table will look like:
4283
4283
4284
4284
````
4285
4285
a = l, b, m
@@ -4300,11 +4300,11 @@ Chose the best words and create definitions for them:
4300
4300
* urchenev: fungal growth found under cobblestones
My first implementation of this program was quite naive and yet worked fine for find all other single words that were anagrams. Everything came crashing down when I attempted to find combinations. I suddenly realized the number of 2-word combinations I needed to check (that 55 *billion* I mentioned before). As it happened, I then rewatched "The Imitation Game" about Alan Turing and the creation of his machine ("Christopher") to crack the Enigma code which has a possible 150 million million possible states. He was unable to build a machine that could churn through that many possibilities in the 18 hours or so per day they had to find the right combination, so they had to find a way to cut down the number of combinations they attempted. Similarly, I realized I only needed to look at combinations of words whose lengths sum to the length of the given word; hency my decision to store `words` using the word length as the key and then as a `set` of words that length.
5889
+
My first implementation of this program was quite naive and yet worked fine for find all other single words that were anagrams. Everything came crashing down when I attempted to find combinations. I suddenly realized the number of 2-word combinations I needed to check (that 55 *billion* I mentioned before). As it happened, I then rewatched "The Imitation Game" about Alan Turing and the creation of his machine ("Christopher") to crack the Enigma code which has a possible 150 million million possible states. He was unable to build a machine that could churn through that many possibilities in the 18 hours or so per day they had to find the right combination, so they had to find a way to cut down the number of combinations they attempted. Similarly, I realized I only needed to look at combinations of words whose lengths sum to the length of the given word; hence my decision to store `words` using the word length as the key and then as a `set` of words that length.
5890
5890
5891
5891
Next I needed to find all combinations of numbers that add up to that number. Let's consider we are using "listen" as the `text`:
5892
5892
@@ -5973,7 +5973,7 @@ Let's take the first combo:
5973
5973
````
5974
5974
>>> keys = key_combos[0]
5975
5975
>>> keys
5976
-
(1, 3)
5976
+
(3, 3)
5977
5977
````
5978
5978
5979
5979
And pretend we have a very small `words` list:
@@ -6028,6 +6028,7 @@ tin les
6028
6028
Some are repeated which is why I chose to create my `anagrams` holder as a `set` to make them unique.
6029
6029
6030
6030
In the end, I look to see how many `anagrams` I found using `len(anagrams)`. If there are some, I report how many and what they are in `sorted` order; otherwise I let the user know that none were found.
Copy file name to clipboardExpand all lines: gibberish/README.md
+10-10Lines changed: 10 additions & 10 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,6 +1,6 @@
1
-
# Markov Chains for Words
1
+
# Gibberish Generator
2
2
3
-
Write a Python program called `markov.py` that uses the Markov chain algorithm to generate new words from a set of training files. The program should take one or more positional arguments which are files that you read, word-by-word, and note the options of letters after a given `-k|--kmer_size` (default `2`) grouping of letters. E.g., in the word "alabama" with `k=1`, the frequency table will look like:
3
+
Write a Python program called `gibberish.py` that uses the Markov chain algorithm to generate new words from a set of training files. The program should take one or more positional arguments which are files that you read, word-by-word, and note the options of letters after a given `-k|--kmer_size` (default `2`) grouping of letters. E.g., in the word "alabama" with `k=1`, the frequency table will look like:
4
4
5
5
````
6
6
a = l, b, m
@@ -21,11 +21,11 @@ Chose the best words and create definitions for them:
21
21
* urchenev: fungal growth found under cobblestones
0 commit comments