Skip to content

Instantly share code, notes, and snippets.

@larryprice
Created November 1, 2014 22:22
Show Gist options
  • Save larryprice/70e1910241b84d800185 to your computer and use it in GitHub Desktop.
Save larryprice/70e1910241b84d800185 to your computer and use it in GitHub Desktop.
Daily Programmer Challenge #185
# https://www.reddit.com/r/dailyprogrammer/comments/2jt4cx/10202014_challenge_185_easy_generated_twitter/
import re
p = re.compile('^at')
modified = []
f = open('enable1.txt', 'r')
for line in f:
if p.match(line):
line = line.strip()
modified.append(('@' + line[1:], line))
modified.sort(key=lambda tup: len(tup[1]))
for word in modified[:10]:
print word[0] + " : " + word[1]
for word in modified[-10:]:
print word[0] + " : " + word[1]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment