Skip to content

Instantly share code, notes, and snippets.

@jdp
Last active April 29, 2016 22:53
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jdp/ea8ab777e2b6d6206c61fe444df9b183 to your computer and use it in GitHub Desktop.
Save jdp/ea8ab777e2b6d6206c61fe444df9b183 to your computer and use it in GitHub Desktop.
Solution to Daily Programmer 264
awk 'NF {print $NF}' | tr a-z A-Z | tr -d .,\"—\; |
xargs -n 1 -I % grep '^% ' cmudict-0.7b |
perl -lne 'if (/.*\b((AA|AE|AH|AO|AW|AY|EH|ER|EY|IH|IY|OW|OY|UH|UW).*)/) {print $1}' |
tr -d 0-9 | awk 'BEGIN{i=1} !seen[$0] {seen[$0]=i++} {print seen[$0]}' | tr 1-9 a-j | tr -d '\n'
last-words() {
awk 'NF {print $NF}' | tr a-z A-Z | tr -d .,\"—\;
}
pronunciations() {
xargs -n 1 -I % grep '^% ' cmudict-0.7b
}
rhyme-endings() {
perl -lne 'if (/.*\b((AA|AE|AH|AO|AW|AY|EH|ER|EY|IH|IY|OW|OY|UH|UW).*)/) {print $1}'
}
rhyme-scheme() {
tr -d 0-9 | awk 'BEGIN{i=1} !seen[$0] {seen[$0]=i++} {print seen[$0]}' | tr 1-9 a-j | tr -d '\n'
}
last-words | pronunciations | rhyme-endings | rhyme-scheme
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment