generated from mwc/lab_pipes
109 lines
4.5 KiB
Markdown
109 lines
4.5 KiB
Markdown
# Exercises
|
|
|
|
Answer the following questions (or at least as many as you can figure out) in this document.
|
|
For all the questions, use the 100k words. Give your answer for each exercise, and
|
|
show the command you used to get it. Each question can be answered using a single Terminal
|
|
command, though you might need to use a number of pipes.
|
|
|
|
If you want to be really stylish, put your code inside of backticks like this:
|
|
|
|
`cat words_100k.txt | length | put 10 | equal | count`
|
|
|
|
## 1. What is the longest word?
|
|
cat words_100k.txt | length | order
|
|
28 antidisestablishmentarianism
|
|
also you can use
|
|
cat words_100k.txt | length | order | tail
|
|
|
|
## 2. How many words have two u's in a row?
|
|
cat words_100k.txt | match "uu" | count
|
|
16 words that have two "u's"
|
|
you can also use, but you have to count the lines
|
|
cat words_100k.txt | match "uu"
|
|
|
|
## 3. How many words have the word "cat" in them?
|
|
cat words_100k.txt | match "cat" | count
|
|
893 words have the word "cat"
|
|
|
|
## 4. How many words have all five vowels (aeiou)?
|
|
cat words_100k.txt | match "a.*e.*i.*o.*u" | count
|
|
8 words have all five vowels (aeiou)
|
|
|
|
## 5. Which words have two l's in a row, two m's in a row, and two t's in a row? (they don't have to be in that order)
|
|
Corrected. Needed to use file, words_370k.txt
|
|
cat words_370k.txt | match "ll" | match "tt" | match "mm"
|
|
noncommittally
|
|
|
|
Used incorrect file, words_100k.txt. Nothing printed out, no error messages in terminal.
|
|
cat words_100k.txt | match "l.+l.+m.+m.+t.+t"
|
|
cat words_100k.txt | match "ll.+mm.+tt"
|
|
cat words_100k.txt | match "l.*l.*m.*m.*t.*t"
|
|
There are no words that have two l's, two m's, and two t's each in a row
|
|
If using a match separately for each set of the "letters in a row," then a lot of words will match the criteria.
|
|
cat words_100k.txt | match "ll" | match "mm"
|
|
cat words_100k.txt | match "mm"
|
|
cat words_100k.txt | match "tt"
|
|
cat words_100k.txt | match "ll" | match "tt"
|
|
cat words_100k.txt | match "ll" | match "tt" | match "mm"
|
|
|
|
|
|
|
|
## 6. How many words have sixteen or more letters?
|
|
cat words_100k.txt | length | order | put 16 | lessthan 0 1 -e | count
|
|
696 words have sixteen or more letters
|
|
|
|
?? How is the lessthan 0 1 -e" counting the order of 16 or more letters in a word?
|
|
It's considered less than or equal to? It looks like it's doing the opposite. Abstract.
|
|
|
|
Breaking down to simplier methods trying to solve the larger problem
|
|
|
|
cat words_100k.txt | length | order 1
|
|
1 word with: 28 letters max
|
|
cat words_100k.txt | length | put 16 | equal | count 354
|
|
cat words_100k.txt | length | put 17 | equal | count 207
|
|
cat words_100k.txt | length | put 18 | equal | count 67
|
|
cat words_100k.txt | length | put 19 | equal | count 45
|
|
cat words_100k.txt | length | put 20 | equal | count 16
|
|
cat words_100k.txt | length | put 21 | equal | count 1
|
|
cat words_100k.txt | length | put 22 | equal | count 3
|
|
cat words_100k.txt | length | put 23 | equal | count 2
|
|
cat words_100k.txt | length | put 24 | equal | count 0
|
|
cat words_100k.txt | length | put 25 | equal | count 0
|
|
cat words_100k.txt | length | put 26 | equal | count 0
|
|
cat words_100k.txt | length | put 27 | equal | count 0
|
|
cat words_100k.txt | length | put 28 | equal | count 1
|
|
|
|
## 7. What's the most frequent 10-letter word?
|
|
cat words_100k.txt | length | put 10 | equal | count
|
|
9869
|
|
|
|
## 8. What's the longest word which doesn't have any repeated letters?
|
|
This is correct...
|
|
cat words_100k.txt | length | unique 1 | length | equal 0 2 | order
|
|
13 abcdeilnprtuy 13 unpredictably
|
|
13 abceghiloprty 13 copyrightable
|
|
13 abceilmnoprtu 13 unproblematic
|
|
13 abegiklmnortu 13 troublemaking
|
|
13 acegilmnopsty 13 salpingectomy
|
|
|
|
## 9. What's the longest word which only uses four different letters?
|
|
Corrected
|
|
cat words_100k.txt | unique |length |put 4 |equal |pluck 3 |length |order
|
|
re-read this and write about it..
|
|
Prints out all unique letters with 4-letter words with the length in alphabetical order
|
|
Note: pluck 3 - selects just the word at index 3
|
|
|
|
Tried this, error message. Thinking 4 unique letters
|
|
How do I change the length to sort "4" unique letters?
|
|
cat words_100k.txt | length | unique 1 | length | order -r | head
|
|
Scrolled up to see longest word, elns, 13 senselessness
|
|
cat words_100k.txt | length | unique 1 | length | order -r | head
|
|
cat words_100k.txt | unique
|
|
cat words_100k.txt | unique | length
|
|
|
|
## 10. If you rearrange the letters in "sidebar," what other words can you create?
|
|
cat words_100k.txt | match "s.*i.*d.*e.*b.*a.*r"
|
|
sidebar
|
|
sideboard
|
|
sideboards
|