stuff
This commit is contained in:
		@ -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"))
 | 
			
		||||
@ -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 )
 | 
			
		||||
@ -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)
 | 
			
		||||
 | 
			
		||||
		Reference in New Issue
	
	Block a user