generated from mwc/lab_pipes
the questions within the document. This lab felt different primarily because there weren't any visual elements like the drawing or turtle. I don't know if I was aware of this as I worked on this lab, but it reminded me a bit, after being prompted to think about the thinking, of function composition. At one point, I tried to see if I could make the input for the put command another terminal command, something like put (cat ...). It didn't work, though I have to admit not spending a lot of time looking into whether there was some syntax I was unfamiliar with that would've accomplished that. Similarly, I don't know whether I felt the way I was using the terminal was particularly different than the way we used the terminal in the last unit, like in the lab involving the ship. I think, having used the terminal briefly many years ago, being vaguely aware that the terminal is powerful, and being ignorant of exactly what the terminal can do, it all feels new but within the range of new experiences I was expecting, as much as anyone can expect the unknown. I didn't feel so much as stuck as a bit overwhelmed with the number of commands that were introduced at once. Once I read through the examples carefully, I knew which ones to refer to as I worked through the problems. I don't know that I "learned" them--that is, I don't know if they're committed to long term memory--but I feel like given a similar task and references materials I could perform well, assuming I performed well on this lab.
59 lines
3.4 KiB
Markdown
59 lines
3.4 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?
|
|
The longest word is "antidisestablishmentarianism."
|
|
I use the following command: `cat words_100k.txt | length | order -r | head -n 1 | pluck 1`
|
|
|
|
## 2. How many words have two u's in a row?
|
|
There are 16 words that have two u's in a row.
|
|
I used the following command: `cat words_100k.txt | match "uu" | count`
|
|
|
|
## 3. How many words have the word "cat" in them?
|
|
There are 893 words with the word "cat" in them.
|
|
I used the following command: `cat words_100k.txt | match "cat" | count`
|
|
|
|
## 4. How many words have all five vowels (aeiou)?
|
|
There are 812 words that have all five vowels.
|
|
I used the following command: `cat words_100k.txt | match "a" | match "e" | match "i" | match "o" | match "u" | count`
|
|
|
|
## 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)
|
|
There are no words that have two l's in a row, two m's in a row, and two t's in a row.
|
|
I used the following command: `cat words_100k.txt | match "ll" | match "mm" | match "tt" | count`
|
|
|
|
## 6. How many words have sixteen or more letters?
|
|
There are 696 words that have sixteen or more letters.
|
|
I used the following command: `cat words_100k.txt | length | order -r | put 16 | lessthan 0 1 -e | count`
|
|
|
|
## 7. What's the most frequent 10-letter word?
|
|
The most frequent 10-letter word is "government."
|
|
I used the following command: `cat words_100k.txt | frequency | length 1 | put 10 | equal 0 1 | order 2 -r | head -n 1 | pluck 3`
|
|
|
|
## 8. What's the longest word which doesn't have any repeated letters?
|
|
The longest word that doesn't have any repeated letters is "salpingectomy," which has 13 letters.
|
|
I used the following command: `cat words_100k.txt | length | unique 1 | length | equal 0 2 | order -r | head -n 1 | pluck 3`
|
|
|
|
Edit: I found that there are four words with the same number of letters as "salpingectomy:"
|
|
"troublemaking"
|
|
"unproblematic"
|
|
"copyrightable"
|
|
"unpredictable"
|
|
I found these by manually counting the number of letters in salpingectomy and then using the following command: `cat words_100k.txt | length | unique 1 | length | equal 0 2 | order -r | head -n 10 | put 13 | equal | pluck 4`
|
|
I'm not sure if I hadn't thought to check how I would've known there were ties using the commands I had available to me.
|
|
|
|
## 9. What's the longest word which only uses four different letters?
|
|
The longest word that uses only four different letters is "senselessness."
|
|
I used the following command: `cat words_100k.txt | unique | length | put 4 | equal | length 3 | order -r | head -n 1 | pluck 4`
|
|
|
|
## 10. If you rearrange the letters in "sidebar," what other words can you create?
|
|
The other words that I can create by rearranging the letters in "sidebar" are: "braised" and "seabird."
|
|
I used the following command: `cat words_100k.txt | length | unique 1 | length | equal 0 2 | put 7 | equal | pluck 4 | match "s" | match "i" | match "d" | match "e" | match "b" | match "a" | match "r"`
|