Skip to content

Commit 1031619

Browse files
committed
Modified ex35 and added ex36
1 parent b350507 commit 1031619

File tree

3 files changed

+24
-2
lines changed

3 files changed

+24
-2
lines changed

exercises/ex35.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@
3333
'z':'zulu'}
3434

3535
def icao(txt, icao_pause=1, word_pause=3):
36-
words = txt.split() # Take each word from privided string
36+
words = txt.split() # Take each word from provided string
3737

3838
for word in words: # For every word in the provided string
3939
for char in word: # For every character in the word
@@ -44,4 +44,4 @@ def icao(txt, icao_pause=1, word_pause=3):
4444

4545
#test
4646
icao("Hello world, hi, I'm Nick!", 0.10, 1)
47-
icao("This is gonna take long! Indeed bro, indeed.")
47+
icao("The quick brown Fox jumps over the laZy Dog!")

exercises/ex36.py

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
"""A hapax legomenon (often abbreviated to hapax) is a word which occurs
2+
only once in either the written record of a language, the works of an
3+
author, or in a single text. Define a function that given the file name
4+
of a text will return all its hapaxes. Make sure your program ignores
5+
capitalization."""
6+
7+
def hapax(file_name):
8+
words = [] # Prepare our words list
9+
# Fill the words list
10+
with open(file_name, 'r') as f:
11+
for line in f:
12+
words += line.rstrip().lower().split()
13+
14+
# Filter the hapaxes from the rest
15+
hapaxes = filter(lambda x: words.count(x) == 1, words)
16+
17+
# Return what we need
18+
return hapaxes
19+
20+
#test
21+
print hapax('hapax.txt')

exercises/hapax.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Extreme success results from an extreme personality and comes at the cost of many other things. Extreme success is different from what I suppose you could just consider 'success', so know that you don't have to be Richard or Elon to be affluent and accomplished and maintain a great lifestyle. Your odds of happiness are better that way. But if you're extreme, you must be what you are, which means that happiness is more or less beside the point. These people tend to be freaks and misfits who were forced to experience the world in an unusually challenging way. They developed strategies to survive, and as they grow older they find ways to apply these strategies to other things, and create for themselves a distinct and powerful advantage. They don't think the way other people think. They see things from angles that unlock new ideas and insights. Other people consider them to be somewhat insane.

0 commit comments

Comments
 (0)