This commit is contained in:
William Mantly 2023-09-23 14:58:28 -04:00
parent 1e1e8f1f03
commit 385dafd1d1
3 changed files with 34 additions and 2 deletions

View File

@ -1,2 +1,15 @@
def remove_duplicate(string):
pass
last = ''
dups = ''
new_string = ''
for char in string:
if last == char:
dups += char
else:
new_string += char
last = char
return new_string, dups
print(remove_duplicate("balloons"))

View File

@ -12,3 +12,9 @@ def get_totatives(num):
def totient(num):
pass
assert( compute_divisors(60) == [1, 2, 3, 4, 5, 6, 10, 12, 15, 20, 30, 60] )
assert( sum_of_divisors(60) == 168 )
assert( divisor_count(60) == 12 )
assert( get_totatives(30) == [1, 7, 11, 13, 17, 19, 23, 29] )
assert( totient(30) == 8 )

View File

@ -1,2 +1,15 @@
def word_stats(filename, n):
pass
words = open(filename).read().replace('\n', '').lower().split()
words = [''.join(e for e in w if e.isalpha()) for w in words]
out = {}
for word in words:
if word in out.keys():
out[word]['count'] += 1
else:
out[word] = {'count': 0, 'word': word}
out = sorted(out, key=lambda x:x[0])
return out
o = word_stats('article.txt', 5)