generated from mwc/lab_pipes
64 lines
2.1 KiB
Markdown
64 lines
2.1 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 -r | head -n 1`
|
|
28 antidisestablishmentarianism
|
|
|
|
|
|
## 2. How many words have two u's in a row?
|
|
`cat words_100k.txt| match "uu" | count`
|
|
16
|
|
|
|
|
|
## 3. How many words have the word "cat" in them?
|
|
`cat words_100k.txt| match "cat" | count`
|
|
893
|
|
|
|
|
|
## 4. How many words have all five vowels (aeiou)?
|
|
`cat words_100k.txt| match "a" | match "e" | match "i" | match "o" | match "u" | count`
|
|
812
|
|
|
|
|
|
## 5. Which words have two e's in a row, two o's in a row, and two k's in a row? (they don't have to be in that order)
|
|
`cat words_100k.txt| match "ee" | match "oo" | match "kk"`
|
|
bookkeeper
|
|
bookkeepers
|
|
bookkeeping
|
|
|
|
|
|
## 6. How many words have sixteen or more letters?
|
|
`cat words_100k.txt| length |put 16|lessthan 1 0|count`
|
|
99304 (THe answser should be 696, which is 100k - 99304. I don't know how to do 'greater than', so I used lessthan command.
|
|
|
|
|
|
## 7. What's the most frequent 10-letter word?
|
|
`cat words_100k.txt | frequency| order -r |length 1 | put 10 |equal| head -n 1|pluck 3`
|
|
government
|
|
|
|
|
|
## 8. What's the longest word which doesn't have any repeated letters?
|
|
`cat words_100k.txt|length | order -r | unique 1 | length 0 | equal 0 2 | head -n 1 | pluck 3`
|
|
unproblematic
|
|
|
|
## 9. What's the longest word which only uses four different letters?
|
|
`cat words_100k.txt| length | order -r | unique 1| length 0 | put 4 | equal 0 1 | head -n 1 | pluck 4`
|
|
senselessness
|
|
|
|
|
|
## 10. If you rearrange the letters in "sidebar," what other words can you create?
|
|
`cat words_100k.txt| match "s" | match "i" |match "d" | match "e"|match "b" |match "a" | match "r" | length |put 7 |equal 0 1 |pluck 2`
|
|
braised
|
|
seabird
|
|
sidebar
|
|
|